Submission #1452780
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader tec = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); for (String line; (line = tec.readLine()) != null;) { StringTokenizer st = new StringTokenizer(line); long a=Long.parseLong(st.nextToken()); long b=Long.parseLong(st.nextToken()); long cont=0; if(a==b){ out.println(0); continue; } if(a<b){ if(a<0&&b>0){ cont++; } }else{ if(b>0&&a>0){ cont+=2; } if(b<=0&&a>=0){ cont++; } if(b<0&&a<0){ cont+=2; } } cont+=Math.abs(Math.abs(a)-Math.abs(b)); out.println(cont); } out.close(); } }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | vjudge1 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 897 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 23252 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | 76 ms | 19668 KB |
0_01.txt | AC | 70 ms | 17620 KB |
0_02.txt | AC | 79 ms | 20944 KB |
1_00.txt | AC | 71 ms | 20948 KB |
1_01.txt | AC | 80 ms | 19156 KB |
1_02.txt | AC | 69 ms | 18260 KB |
1_03.txt | AC | 71 ms | 18644 KB |
1_04.txt | AC | 67 ms | 21204 KB |
1_05.txt | AC | 69 ms | 23252 KB |
1_06.txt | AC | 70 ms | 21332 KB |
1_07.txt | AC | 72 ms | 22484 KB |
1_08.txt | AC | 69 ms | 19156 KB |
1_09.txt | AC | 69 ms | 17492 KB |
1_10.txt | AC | 70 ms | 18132 KB |