Submission #1041810
Source Code Expand
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <queue> #include <iomanip> #include <utility> using namespace std; #define REP(i,n) for(int i = 0; i < n; i++) #define MOD 1000000007 int main(int argc, char const *argv[]) { int x,y; cin >> x >> y; bool fugox = true; bool fugoy = true; if(x < 0) fugox = false; if(y <= 0) fugoy = false; int absx = abs(x); int absy = abs(y); if(fugox && fugoy){//両方正 if(y - x >= 0){ cout << y-x << endl; }else{ cout << x-y+2 << endl; } }else if(fugox && !fugoy){ if(absy >= absx){ cout << absy-absx+1 << endl; }else{ cout << absx-absy+1 << endl; } }else if(!fugox && fugoy){ if(absy >= absx){ cout << absy-absx+1 << endl; }else{ cout << absx-absy+1 << endl; } }else{//両方負 if(absy > absx){ cout << absy-absx+2 << endl; }else{ cout << absx-absy << endl; } } }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | teamhimeH |
Language | C++14 (Clang 3.8.0) |
Score | 300 |
Code Size | 1029 Byte |
Status | AC |
Exec Time | 6 ms |
Memory | 888 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 | 6 ms | 888 KB |
0_01.txt | AC | 3 ms | 256 KB |
0_02.txt | AC | 2 ms | 256 KB |
1_00.txt | AC | 3 ms | 256 KB |
1_01.txt | AC | 2 ms | 256 KB |
1_02.txt | AC | 2 ms | 256 KB |
1_03.txt | AC | 2 ms | 256 KB |
1_04.txt | AC | 3 ms | 256 KB |
1_05.txt | AC | 3 ms | 256 KB |
1_06.txt | AC | 2 ms | 256 KB |
1_07.txt | AC | 3 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 3 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |