Submission #527673
Source Code Expand
/*{{{*/ #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <functional> #include <bitset> #include <deque> #include <list> #include <map> #include <queue> #include <set> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> #include <iostream> #include <string> #include <sstream> using namespace std; typedef int8_t sbyte; typedef uint8_t byte; typedef uint16_t ushort; typedef uint32_t uint; typedef int64_t i64; typedef uint64_t u64; template<class T> static inline T ABS(T x) {return x < 0 ? -x : x;} template<class T> static inline void MAZ(T &a, const T &b) {if(a < b) a = b;} template<class T> static inline void MIZ(T &a, const T &b) {if(b < a) a = b;} /*}}}*/ static inline i64 S(int d) { return 1 + (i64)d * (d + 1) * 2; } static int D(i64 k) { auto _l = 0, _r = 710000000; while(_l < _r) { auto _m = _l + _r >> 1; if(S(_m) >= k) { _r = _m; } else { _l = _m + 1; } } return _l; } int main() { int T; for(scanf("%d", &T); T > 0; T--) { i64 k; scanf("%lld", &k); if(k == 1) { puts("0 0"); } else { auto d = D(k); if(k == S(d)) { printf("%d 0\n", d); } else { k -= S(d - 1); if(k == 1) { printf("%d 0\n", -d); } else { int x = -d + k / 2; int y = k / 2; if(y > d) y = d + d - y; if(k % 2 == 0) y = -y; printf("%d %d\n", x, y); } } } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - n-th Points |
User | arosusti |
Language | C++11 (GCC 4.8.1) |
Score | 100 |
Code Size | 1591 Byte |
Status | AC |
Exec Time | 166 ms |
Memory | 1148 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:56:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(scanf("%d", &T); T > 0; T--) { ^ ./Main.cpp:58:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &k); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt |
All | subtask0_sample_01.txt, subtask1_large_01.txt, subtask1_mini01.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | AC | 29 ms | 1036 KB |
subtask1_large_01.txt | AC | 125 ms | 1012 KB |
subtask1_mini01.txt | AC | 90 ms | 952 KB |
subtask1_random01.txt | AC | 100 ms | 1040 KB |
subtask1_random02.txt | AC | 100 ms | 920 KB |
subtask1_random03.txt | AC | 136 ms | 988 KB |
subtask1_random04.txt | AC | 166 ms | 1016 KB |
subtask1_random05.txt | AC | 163 ms | 916 KB |
subtask1_random06.txt | AC | 164 ms | 984 KB |
subtask1_random07.txt | AC | 161 ms | 924 KB |
subtask1_random08.txt | AC | 164 ms | 1148 KB |