Submission #1476457
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author david yepes buitrago * @date 01-08-2017 * @time 0.000 ms */ public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); for (String line; (line = in.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 | Java7 (OpenJDK 1.7.0) |
Score | 300 |
Code Size | 1024 Byte |
Status | AC |
Exec Time | 75 ms |
Memory | 20820 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 | 74 ms | 18900 KB |
0_01.txt | AC | 74 ms | 20692 KB |
0_02.txt | AC | 75 ms | 18644 KB |
1_00.txt | AC | 75 ms | 20820 KB |
1_01.txt | AC | 74 ms | 20436 KB |
1_02.txt | AC | 75 ms | 16852 KB |
1_03.txt | AC | 75 ms | 18644 KB |
1_04.txt | AC | 74 ms | 20564 KB |
1_05.txt | AC | 74 ms | 18644 KB |
1_06.txt | AC | 74 ms | 20308 KB |
1_07.txt | AC | 74 ms | 20564 KB |
1_08.txt | AC | 73 ms | 18772 KB |
1_09.txt | AC | 73 ms | 18644 KB |
1_10.txt | AC | 74 ms | 18900 KB |