Submission #1496919
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int y=sc.nextInt(); int ans=0; if(x<y && x*y<0){ if(-x>y){ ans=y-x; }else{ ans=1+y+x; } }else if(x<y && x*y>=0){ ans=y-x; }else if(x>y && x*y<=0){ if(-y<x){ ans=1+x+y; }else{ ans=-y-x+1; } }else if(x>y && x*y>0){ ans=1+x-y+1; } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 540 Byte |
Status | WA |
Exec Time | 106 ms |
Memory | 25684 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 90 ms | 19796 KB |
0_01.txt | AC | 90 ms | 19924 KB |
0_02.txt | AC | 91 ms | 21844 KB |
1_00.txt | WA | 90 ms | 21716 KB |
1_01.txt | AC | 90 ms | 19924 KB |
1_02.txt | AC | 90 ms | 18644 KB |
1_03.txt | AC | 91 ms | 25684 KB |
1_04.txt | AC | 106 ms | 21972 KB |
1_05.txt | AC | 91 ms | 20564 KB |
1_06.txt | WA | 90 ms | 21076 KB |
1_07.txt | WA | 92 ms | 20052 KB |
1_08.txt | AC | 91 ms | 17620 KB |
1_09.txt | WA | 105 ms | 19796 KB |
1_10.txt | AC | 92 ms | 17620 KB |