Submission #2125007
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
typedef long long ll;
using namespace std;
const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;
//while(x!=0){
//sum+=x%10;
// x/=10;
//}
//各桁の和
//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力
//s.find(w[i])==string::npos
//findの使い方
//for(int i=0;i<n;i++){
// b[i]=x%2;
//x/=2;
//}二進数
long long int n=1,cnt=0,ans=0,a,b,c,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;
string s,w;
vector<int> z;
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> x >> y;
if(x==y){
Cout(0);
return 0;
}
if(x<0 && y==0){
cmp=x*-1;
Cout(cmp);
return 0;
}
if(x>=0 && y>=0){
if(x<=y){
Cout(Abs(x,y));
}
else{
Cout(Abs(x,y)+2);
}
}
else if(x>=0 && y<0){
cmp=y*-1;
Cout(Abs(x,cmp)+1);
}
else if(x<0 && y>=0){
//if(x*-1<=y){
cmp=x*-1;
Cout(Abs(cmp,y)+1);
//}
//else{
//}
}
else{
if(x*-1<=y*-1){
cmp=x*-1;
cmpp=y*-1;
Cout(Abs(cmp,cmpp)+2);
}
else{
cmp=x*-1;
cmpp=y*-1;
Cout(Abs(cmp,cmpp));
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Simple Calculator |
User |
asdf1 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2149 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
WA |
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 |