Submission #305990
Source Code Expand
#include <stdio.h> #ifdef WIN32 char strll[10]="%I64d"; #else char strll[10]="%lld"; #endif long long n; int Q; long long GetSqrt(long long x) { long long l=0,r=1000000000; long long mid=(l+r)/2; long long f; while(l<r) { mid=(l+r+1)/2; f=2*mid*(mid+1); if(f<x) { l=mid; } else { r=mid-1; } } return l; } long long abs(long long x) { return x>0?x:-x; } long long dig(long long x) { if(x==0) return 0; return x>0?1:-1; } int main() { long long lvl,ys; scanf("%d",&Q); for(int T=1; T<=Q; ++T) { scanf(strll,&n); n-=1; if(n==0) { printf("0 0\n"); continue; } lvl=GetSqrt(n)+1; ys=n-2*lvl*(lvl-1); if(ys==1) { printf(strll,-lvl); printf(" 0\n"); } else if(ys==4*lvl) { printf(strll,lvl); printf(" 0\n"); } else { printf(strll,ys/2-lvl); printf(" "); printf(strll,((ys%2)*2-1)*(lvl-abs(ys/2-lvl))); printf("\n"); } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - n-th Points |
User | asian-2014-1515 |
Language | C++ (G++ 4.6.4) |
Score | 100 |
Code Size | 997 Byte |
Status | AC |
Exec Time | 150 ms |
Memory | 800 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:41:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] ./Main.cpp:44:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
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 | 20 ms | 792 KB |
subtask1_large_01.txt | AC | 124 ms | 664 KB |
subtask1_mini01.txt | AC | 83 ms | 792 KB |
subtask1_random01.txt | AC | 123 ms | 668 KB |
subtask1_random02.txt | AC | 124 ms | 772 KB |
subtask1_random03.txt | AC | 124 ms | 784 KB |
subtask1_random04.txt | AC | 148 ms | 800 KB |
subtask1_random05.txt | AC | 146 ms | 672 KB |
subtask1_random06.txt | AC | 150 ms | 796 KB |
subtask1_random07.txt | AC | 121 ms | 792 KB |
subtask1_random08.txt | AC | 126 ms | 796 KB |