Submission #1041492
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define X first #define Y second typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; #define debug(x) cerr << #x << " = " << (x) << endl; template<typename T> ostream& operator<<(ostream& o, vector<T>& v) { for (auto& x : v) o << x << ' '; return o; } int main(){ std::ios_base::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; int res; if (a >= 0 && b >= 0) { if (b >= a) res = b - a; else if (b == 0) res = 1 + (a - b); else res = 2 + (a - b); } else if (a >= 0){ res = 1 + abs(a + b); } else if (b >= 0){ if (b == 0) res = abs(a + b); else res = 1 + abs(a + b); } else { if (b >= a) res = b - a; else res = 2 + (a - b); } cout << res << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | I3MNIX |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 903 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 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 | 2 ms | 256 KB |
0_01.txt | AC | 2 ms | 256 KB |
0_02.txt | AC | 2 ms | 256 KB |
1_00.txt | AC | 2 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 | 2 ms | 256 KB |
1_05.txt | AC | 2 ms | 256 KB |
1_06.txt | AC | 2 ms | 256 KB |
1_07.txt | AC | 2 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 2 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |