Submission #1041130


Source Code Expand

#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll x,y;

void run() {
	scanf("%lld%lld",&x,&y);

	ll ret=abs(abs(x)-abs(y));
	if(x>=0) {
		if(y>=x) {
			//nothing
		} else if(y>=0) {
			ret+=2;
		} else {
			ret++;
		}
	} else {
		if(y<=x) {
			ret+=2;
		} else if(y<=0) {
			//nothing
		} else {
			ret++;
		}
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}

Submission Info

Submission Time
Task A - Simple Calculator
User krijgertje
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1154 Byte
Status WA
Exec Time 43 ms
Memory 764 KB

Compile Error

./Main.cpp: In function ‘void run()’:
./Main.cpp:36:25: 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
AC × 3
AC × 13
WA × 1
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 43 ms 764 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 WA 3 ms 256 KB
1_04.txt AC 2 ms 256 KB
1_05.txt AC 2 ms 256 KB
1_06.txt AC 3 ms 256 KB
1_07.txt AC 2 ms 256 KB
1_08.txt AC 3 ms 256 KB
1_09.txt AC 3 ms 256 KB
1_10.txt AC 2 ms 256 KB