Submission #595217
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
2015-12-16 19:43:43+0900
Task
B - n-th Points
User
natsugiri
Language
C++ (G++ 4.6.4)
Score
100
Code Size
1347 Byte
Status
AC
Exec Time
165 ms
Memory
1016 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]
./Main.cpp:35: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
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
127 ms
956 KB
subtask1_large_01.txt
AC
155 ms
952 KB
subtask1_mini01.txt
AC
93 ms
952 KB
subtask1_random01.txt
AC
129 ms
956 KB
subtask1_random02.txt
AC
132 ms
1016 KB
subtask1_random03.txt
AC
136 ms
952 KB
subtask1_random04.txt
AC
165 ms
956 KB
subtask1_random05.txt
AC
160 ms
888 KB
subtask1_random06.txt
AC
156 ms
952 KB
subtask1_random07.txt
AC
156 ms
956 KB
subtask1_random08.txt
AC
154 ms
944 KB