Submission #1219409
Source Code Expand
#include <stdio.h> #include <iostream> #include <cmath> #define int long long using namespace std; const int N=123456; int Abs(int a) { return a>=0?a:-a; } signed main() { int x,y; scanf("%lld %lld",&x,&y); if(x>=0 && y>=0) { if(x<=y) { printf("%lld\n",y-x); } else { printf("%lld\n",min(x-y+2,y+x+1)); } } else if(x>=0 && y<=0) { if(Abs(x)<=Abs(y)) { printf("%lld\n",Abs(y)-Abs(x)+1); } else { puts("fdsa"); printf("%lld\n",Abs(x)-Abs(y)+1); } } else if(x<=0 && y>=0) { if(Abs(x)>=Abs(y)) { printf("%lld\n",min(Abs(x)-Abs(y)+1,Abs(x)+Abs(y))); } else { printf("%lld\n",min(Abs(y)+Abs(x),Abs(y)-Abs(x)+2)); } } else { if(Abs(x)>=Abs(y)) { printf("%lld\n",Abs(x)-Abs(y)); } else { printf("%lld\n",Abs(y)-Abs(x)+2); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | hanssy |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 846 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:17:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld %lld",&x,&y); ^
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 | 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 | WA | 1 ms | 256 KB |
1_08.txt | WA | 1 ms | 256 KB |
1_09.txt | AC | 1 ms | 256 KB |
1_10.txt | AC | 1 ms | 256 KB |