Submission #1041484
Source Code Expand
//#include "IntMod.h" //typedef IntMod<1000000007> MInt; //#include "Union_Find.h" #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> //#include <unordered_set> //#include <unordered_map> #include <iomanip> #include <sstream> using namespace std; #define REP(i,a,n) for(int i = a; i < n; ++i) #define REPM(i,n,a) for(int i = n - 1; i >= a; --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 typedef long long LL; typedef unsigned long long ULL; class SplitStream { typedef basic_ostream<char, char_traits<char> > BaseOst; std::ostream& ost_m; bool line_is_empty_m; public: SplitStream(std::ostream& ost); template <typename T> SplitStream& operator<<(T right); SplitStream& operator<<(BaseOst& (*right)(BaseOst&)); }; SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {} template <typename T> SplitStream& SplitStream::operator<<(T right) { if (!line_is_empty_m) ost_m << ' '; line_is_empty_m = false; ost_m << right; return *this; } /* std::endl のみ */ SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) { ost_m << '\n'; ost_m.flush(); line_is_empty_m = true; return *this; } SplitStream Scout(cout); template <typename T, int Begin, int End> class OffsetArray { T arr_m[End - Begin]; public: OffsetArray(); T& operator[](int index); T operator[](int index) const; }; template<typename T, int Begin, int End> OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {} template<typename T, int Begin, int End> T& OffsetArray<T, Begin, End>::operator[](int index) { return arr_m[index - Begin]; } template<typename T, int Begin, int End> T OffsetArray<T, Begin, End>::operator[](int index) const { return arr_m[index - Begin]; } int X, Y; int main() { cin >> X >> Y; int ret; if ((LL)X * Y >= 0) { if (Y >= X) { ret = Y - X; } else { if (Y == 0) { ret = X + 1; } else if (X == 0) { ret = 1 - Y; } else { ret = X - Y + 2; } } } else { ret = abs(X + Y) + 1; } cout << ret << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Simple Calculator |
User | Aquarius |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 2366 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | 2 ms | 256 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 | AC | 2 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 | 2 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 2 ms | 256 KB |
1_10.txt | AC | 2 ms | 256 KB |