Submission #305762


Source Code Expand

#include <cstdio>

long long calc_inside(long long vl) {
	if(vl==0) return 0;
	if(vl==1) return 1;
	if(vl==2) return 5;
	return (vl-1)*vl*2+1;
}
long long getabs(long long x) {
	if(x<0) return -x;
	return x;
}
int main() {
	int Q;
	long long n;
	scanf("%d",&Q);
	for(int qi=0;qi<Q;qi++) {
		scanf("%lld",&n);
		long long abssummin=0;
		long long abssummax=1100000000;
		while(abssummin<abssummax) {
			long long hf=(abssummin+abssummax+1)/2;
			if(calc_inside(hf)>=n) {
				abssummax=hf-1;
			} else {
				abssummin=hf;
			}
		}
		if(n==calc_inside(abssummin)+1) {
			printf("%lld 0\n",-abssummin);
		} else if(n==calc_inside(abssummin+1)){
			printf("%lld 0\n",abssummin);
		} else {
			long long dx=-abssummin+(n-calc_inside(abssummin))/2;
			if((n-calc_inside(abssummin))%2) {
				printf("%lld %lld\n",dx,abssummin-getabs(dx));
			} else {
				printf("%lld %lld\n",dx,getabs(dx)-abssummin);
			}
		}
	}
	return 0;
}

Submission Info

Submission Time
Task B - n-th Points
User phidnight
Language C++ (G++ 4.6.4)
Score 100
Code Size 962 Byte
Status AC
Exec Time 140 ms
Memory 800 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:18: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 23 ms 708 KB
subtask1_large_01.txt AC 140 ms 796 KB
subtask1_mini01.txt AC 85 ms 796 KB
subtask1_random01.txt AC 135 ms 796 KB
subtask1_random02.txt AC 134 ms 796 KB
subtask1_random03.txt AC 134 ms 668 KB
subtask1_random04.txt AC 130 ms 800 KB
subtask1_random05.txt AC 131 ms 720 KB
subtask1_random06.txt AC 128 ms 792 KB
subtask1_random07.txt AC 130 ms 668 KB
subtask1_random08.txt AC 131 ms 800 KB