Submission #695078
Source Code Expand
#include<cmath>
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...) fprintf(stderr, s)
template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }
LL my_sqrt(LL x) {
LL hi = x, lo = 0;
while (hi -lo > 1) {
LL m = (hi + lo) >> 1;
(m*m <= x? lo : hi) = x;
}
return lo;
}
int Q;
LL N;
int main() {
scanf("%d", &Q);
REP ($, Q) {
scanf("%lld", &N);
if (N == 1) {
puts("0 0");
continue;
}
N--;
LL lo = 0, hi = 1LL<<31;
while (hi - lo > 1) {
LL m = (hi + lo) >> 1;
(m * (m+1) * 2 < N ? lo : hi) = m;
}
LL p = hi;
LL b = (p-1)*p*2 + 1;
if (N-b < 2*p) {
if (N % 2) printf("%lld %lld\n", -p+(N-b)/2, (N-b)/2);
else printf("%lld %lld\n", -p+(N-b+1)/2, -(N-b+1)/2);
} else {
if (N % 2) printf("%lld %lld\n", (N-b-2*p)/2, p - (N-b-2*p)/2);
else printf("%lld %lld\n", (N-b-2*p+1)/2, -p + (N-b-2*p + 1)/2);
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - n-th Points |
User |
wuyiqi |
Language |
C++11 (GCC 4.8.1) |
Score |
100 |
Code Size |
1354 Byte |
Status |
AC |
Exec Time |
154 ms |
Memory |
916 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:33:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &Q);
^
./Main.cpp:35:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
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 |
28 ms |
788 KB |
subtask1_large_01.txt |
AC |
149 ms |
812 KB |
subtask1_mini01.txt |
AC |
89 ms |
788 KB |
subtask1_random01.txt |
AC |
105 ms |
788 KB |
subtask1_random02.txt |
AC |
127 ms |
820 KB |
subtask1_random03.txt |
AC |
130 ms |
788 KB |
subtask1_random04.txt |
AC |
149 ms |
888 KB |
subtask1_random05.txt |
AC |
151 ms |
880 KB |
subtask1_random06.txt |
AC |
148 ms |
916 KB |
subtask1_random07.txt |
AC |
153 ms |
792 KB |
subtask1_random08.txt |
AC |
154 ms |
796 KB |