Submission #305832
Source Code Expand
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; int main() { int Q; scanf("%d", &Q); for(int ii = 0; ii < Q; ++ii) { long long n; scanf("%lld", &n); if(n==1) { printf("%d %d\n", 0, 0); continue; } int lo=1, hi=707106782; while(hi-lo>1) { int mid=(hi+lo)/2; if(2LL*mid*(mid-1)+2 <= n) lo=mid; else hi=mid; } long long idx = n-(2LL*lo*(lo-1)+2); // fprintf(stderr, "lo=%d, idx=%d\n", lo, idx); long long x = (idx+1)/2-lo; long long y = (idx&1) ? abs(x)-lo : lo-abs(x); printf("%lld %lld\n", x, y); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - n-th Points |
User | qnighy |
Language | C++11 (GCC 4.8.1) |
Score | 100 |
Code Size | 625 Byte |
Status | AC |
Exec Time | 160 ms |
Memory | 804 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:7:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int Q; scanf("%d", &Q); ^ ./Main.cpp:9:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] long long n; scanf("%lld", &n); ^
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 | 23 ms | 792 KB |
subtask1_large_01.txt | AC | 135 ms | 676 KB |
subtask1_mini01.txt | AC | 98 ms | 800 KB |
subtask1_random01.txt | AC | 111 ms | 668 KB |
subtask1_random02.txt | AC | 110 ms | 796 KB |
subtask1_random03.txt | AC | 134 ms | 796 KB |
subtask1_random04.txt | AC | 155 ms | 668 KB |
subtask1_random05.txt | AC | 160 ms | 792 KB |
subtask1_random06.txt | AC | 158 ms | 804 KB |
subtask1_random07.txt | AC | 150 ms | 796 KB |
subtask1_random08.txt | AC | 156 ms | 804 KB |