Submission #1041802


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int x, y; cin >> x >> y;
	int ans = abs(abs(x) - abs(y));
	if ((x * y < 0) || (x == 0 && y < 0) || (x > 0 && y == 0)) {
		ans++;
	} else {
		if (x > y) ans += 2;
	}

	cout << ans << endl;
	system("pause");
}

Submission Info

Submission Time
Task A - Simple Calculator
User tosaka2
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1289 Byte
Status AC
Exec Time 4 ms
Memory 504 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:42:17: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 14
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 4 ms 504 KB
0_01.txt AC 4 ms 504 KB
0_02.txt AC 4 ms 504 KB
1_00.txt AC 4 ms 504 KB
1_01.txt AC 4 ms 504 KB
1_02.txt AC 4 ms 500 KB
1_03.txt AC 4 ms 504 KB
1_04.txt AC 4 ms 500 KB
1_05.txt AC 4 ms 504 KB
1_06.txt AC 4 ms 504 KB
1_07.txt AC 4 ms 504 KB
1_08.txt AC 4 ms 504 KB
1_09.txt AC 4 ms 504 KB
1_10.txt AC 4 ms 504 KB