Submission #1043079
Source Code Expand
#include<iostream> #include<iostream> #include<stdio.h> #include<string> #include<vector> #include<map> #include<math.h> #include<algorithm> #include<iomanip> using namespace std; class Counting { unsigned long long p, n; vector<long long> invMemo, facMemo, facInvMemo; public: Counting(unsigned long long nn, unsigned long long np) { p = np; n = nn; invMemo.resize(n + 1); facMemo.resize(n + 1); facInvMemo.resize(n + 1); facMemo[0] = 1; facMemo[1] = 1; facInvMemo[0] = 1; facInvMemo[1] = 1; invMemo[0] = 0; invMemo[1] = 1; for (unsigned long long i = 2; i <= n; i++) { invMemo[i] = p - (p / i)*invMemo[p%i] % p; facMemo[i] = (facMemo[i - 1] * i) % p; facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p; } } unsigned long long fac(unsigned long long k) { return facMemo[k]; } unsigned long long facInv(unsigned long long k) { return facInvMemo[k]; } unsigned long long choose(unsigned long long n, unsigned long long k) { if (!(0 <= k && k <= n)) return 0; return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p; } unsigned long long divide(unsigned long long a, unsigned long long b) { return (a * invMemo[b]) % p; } unsigned long long mod(unsigned long long a) { a %= p; if (a < 0) a += p; return a; } unsigned long long power(unsigned long long a, unsigned long long e) { unsigned long long ans = 1; for (; e > 0; e /= 2) { if (e % 2 != 0) ans = ans * a % p; a = a*a%p; } return ans; } }; long long a, b, aa, bb, ans = 0; int main() { cin >> a >> b; aa = -a; bb = -b; long long a1 = 10000000000, a2 = 10000000000, a3 = 10000000000, a4 = 10000000000; if (b >= a) { a1 = 0; a1 += b - a; } if (b >= aa) { a2 = 1; a2 += b - aa; } if (bb >= a) { a3 = 1; a3 += bb - a; } if (bb >= aa) { a4 = 2; a4 += bb - aa; } ans = min(a1, a2); ans = min(ans, a3); ans = min(ans, a4); cout << ans << endl; // cin >> a; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | ninja7 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 2042 Byte |
Status | AC |
Exec Time | 3 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 | 3 ms | 256 KB |
0_01.txt | AC | 3 ms | 256 KB |
0_02.txt | AC | 3 ms | 256 KB |
1_00.txt | AC | 3 ms | 256 KB |
1_01.txt | AC | 2 ms | 256 KB |
1_02.txt | AC | 3 ms | 256 KB |
1_03.txt | AC | 3 ms | 256 KB |
1_04.txt | AC | 3 ms | 256 KB |
1_05.txt | AC | 3 ms | 256 KB |
1_06.txt | AC | 3 ms | 256 KB |
1_07.txt | AC | 3 ms | 256 KB |
1_08.txt | AC | 3 ms | 256 KB |
1_09.txt | AC | 3 ms | 256 KB |
1_10.txt | AC | 3 ms | 256 KB |