http://acm.hust.edu.cn/vjudge/contest/121398#problem/B
#include<stdio.h> #include<string.h> #include<math.h> #include<queue> #include<algorithm> using namespace std; typedef long long LL; #define maxn 450000 #define oo 0x3f3f3f3f int main() { int T, t = 1; long long n, m, k, x, y; scanf("%d", &T); while(T --) { scanf("%lld", &n); m = sqrt(n); k = n - m * m; if(m % 2 == 0) { if(!k) { x = m; y = 1; } else if(k <= m+1) { x = m + 1; y = k; } else { y = m + 1; x = m - (k - m - 2); } } else { if(!k) { y = m; x = 1; } else if(k <= m+1) { y = m + 1; x = k; } else { x = m + 1; y = m - (k - m - 2); } } printf("Case %d: %lld %lld ", t++, x, y); } return 0; }