提出 #1041117
ソースコード 拡げる
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <vector> #include <sstream> #include <set> using namespace std; using ll = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n; public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}}; int main() { int x, y; while (cin >> x >> y) { int res = 2100000000; // x->y if (x <= y) res = min(res, y - x); // x->-x->y if (-x <= y) res = min(res, 1 + y - (-x)); // x->-y->y if (x <= -y) res = min(res, 1 + (-y - x)); // x->-x->-y->y if (-x <= -y) res = min(res, 2 + (-y - (-x))); cout << res << endl; } }
提出情報
提出日時 | |
---|---|
問題 | A - Simple Calculator |
ユーザ | ir5 |
言語 | C++14 (GCC 5.4.1) |
得点 | 300 |
コード長 | 866 Byte |
結果 | AC |
実行時間 | 3 ms |
メモリ | 256 KB |
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 300 / 300 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
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 |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
0_00.txt | AC | 2 ms | 256 KB |
0_01.txt | AC | 2 ms | 256 KB |
0_02.txt | AC | 2 ms | 256 KB |
1_00.txt | AC | 3 ms | 256 KB |
1_01.txt | AC | 3 ms | 256 KB |
1_02.txt | AC | 2 ms | 256 KB |
1_03.txt | AC | 3 ms | 256 KB |
1_04.txt | AC | 2 ms | 256 KB |
1_05.txt | AC | 2 ms | 256 KB |
1_06.txt | AC | 2 ms | 256 KB |
1_07.txt | AC | 3 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 3 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |