Submission #1831759
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define repr(i,n) for(int i=(int)(n-1);i>=0;i--) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define all(x) (x).begin(),(x).end() #define dbg(x) cout << #x" = " << x << endl #define print(x) cout << x << endl #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt(x) bitset<32>(x).count() typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> PPI; typedef pair<int, P> PIP; typedef pair<ll, ll> PL; typedef pair<P, ll> PPL; typedef set<int> S; #define INF INT_MAX/3 #define MAX_N 1000000001 int main(){ cin.sync_with_stdio(false); int x, y; cin >> x >> y; int ans = 0; if (abs(x) < abs(y)) { ans += abs(y) - abs(x); if ((x >= 0 && y < 0) || (x < 0 && y > 0)) ans++; else if (x < 0 && y < 0) ans += 2; } else if (abs(x) > abs(y)) { ans = abs(x) - abs(y); if (x < 0 && y > 0 || (x > 0 && y <= 0)) ans++; else if (x > 0 && y > 0) ans += 2; } else if (x != y) ans = 1; cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | zura |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1377 Byte |
Status | AC |
Exec Time | 1 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 | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | AC | 1 ms | 256 KB |
1_03.txt | AC | 1 ms | 256 KB |
1_04.txt | AC | 1 ms | 256 KB |
1_05.txt | AC | 1 ms | 256 KB |
1_06.txt | AC | 1 ms | 256 KB |
1_07.txt | AC | 1 ms | 256 KB |
1_08.txt | AC | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 1 ms | 256 KB |