Submission #1496912
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=Math.min(1+(x-y)+1,-y-x+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 | 559 Byte |
Status | WA |
Exec Time | 96 ms |
Memory | 21844 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 | 91 ms | 21716 KB |
0_01.txt | AC | 92 ms | 20816 KB |
0_02.txt | AC | 92 ms | 20564 KB |
1_00.txt | WA | 94 ms | 19924 KB |
1_01.txt | AC | 93 ms | 21460 KB |
1_02.txt | AC | 92 ms | 20052 KB |
1_03.txt | AC | 93 ms | 20692 KB |
1_04.txt | AC | 94 ms | 18644 KB |
1_05.txt | WA | 94 ms | 17492 KB |
1_06.txt | AC | 92 ms | 21844 KB |
1_07.txt | WA | 90 ms | 18772 KB |
1_08.txt | AC | 96 ms | 20948 KB |
1_09.txt | WA | 93 ms | 19668 KB |
1_10.txt | AC | 91 ms | 19796 KB |