http://acm.hust.edu.cn/vjudge/contest/121398#problem/B
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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\n", t++, x, y); } return 0; }