Submission #305660


Source Code Expand

#include <stdio.h>
#include <math.h>

main(){
	int q;
	scanf("%d",&q);
	for(int t=0;t<q;t++){
		long long n;
		scanf("%lld",&n);
		n--;
		if(n==0)printf("0 0\n");
		else{
			long long k=sqrt((2*n+1)/4);
			long long k0=k-1000;
			if(k0<1)k0=1;
			for(long long l=k0;l<k0+2000;l++){
				if(2*l*(l+1)>=n && 2*l*(l-1)<n){
					long long diff=n-2*l*(l-1);
					long long x,y;
					if(diff%2==0){
						x=-l+diff/2;
						y=-l+(x>0?x:-x);
					}else{
						x=-l+diff/2;
						y=l-(x>0?x:-x);
					}
					printf("%lld %lld\n",x,y);
					break;
				}
			}
		}
	}
}

Submission Info

Submission Time
Task B - n-th Points
User omeometo
Language C++ (G++ 4.6.4)
Score 100
Code Size 591 Byte
Status AC
Exec Time 289 ms
Memory 804 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:6:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:9:19: 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
AC × 1
AC × 11
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 21 ms 800 KB
subtask1_large_01.txt AC 231 ms 800 KB
subtask1_mini01.txt AC 84 ms 788 KB
subtask1_random01.txt AC 221 ms 800 KB
subtask1_random02.txt AC 220 ms 656 KB
subtask1_random03.txt AC 224 ms 728 KB
subtask1_random04.txt AC 238 ms 796 KB
subtask1_random05.txt AC 239 ms 800 KB
subtask1_random06.txt AC 238 ms 796 KB
subtask1_random07.txt AC 289 ms 748 KB
subtask1_random08.txt AC 239 ms 804 KB