Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- long long int t,n,i,j,r,c,x,y,sx,sy,a,b;
- scanf("%lld",&t);
- for(i=1;i<=t;i++){
- scanf("%lld",&n);
- x=sqrt(n);
- y=x+1;
- sx=x*x;
- sy=y*y;
- if(sx==n){
- if(x%2==0){
- r=x;
- c=1;
- }
- else{
- r=1;
- c=x;
- }
- }
- else{
- a=n-sx;
- b=sy-n;
- if(a>b){
- if(y%2==0){
- r=y;
- c=sy-n+1;
- }
- else{
- r=sy-n+1;
- c=y;
- }
- }
- else{
- if(x%2==0){
- r=x+1;
- c=n-sx;
- }
- else{
- r=n-sx;
- c=x+1;
- }
- }
- }
- printf("Case %lld: %lld %lld\n",i,r,c);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement