Advertisement
Anik_Akash

Fibsieve`s Fantabulous Birthday

Oct 12th, 2020 (edited)
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. //thanks God For Every Thing!
  2. //contest link:
  3.  
  4. //#include<bits/stdc++.h>
  5. #include<iostream>
  6. #include<fstream>
  7. #include<string>
  8. #include<algorithm>
  9. #include<cmath>
  10. #include<cstdio>
  11. #define pi           acose(-1)
  12. #define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n');
  13. #define wow          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  14. #define NL           printf("\n")
  15. #define fin          freopen("int.txt","r",stdin);
  16. #define fout         freopen("out.txt","w",stdout);
  17.  
  18. using namespace std;
  19.  
  20. typedef long long int           ll;
  21. typedef double                  dl;
  22.  
  23. // ---------------------- slove---------------------------//
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29.     int t;
  30.     scanf("%d",&t);
  31.     for(int j=1; j<=t; j++)
  32.     {
  33.  
  34.         ll n;
  35.         ll x, last, first, mid, c, r, diff;
  36.         scanf("%lld",&n);
  37.  
  38.         x = (sqrt(n-1))+1;
  39.         last = x*x;
  40.  
  41.         first = ((x-1)*(x-1))+1;
  42.  
  43.         mid = (last+first)/2;
  44.  
  45.         if(n>mid && n<=last)
  46.         {
  47.             c = x;
  48.             diff = last-n;
  49.             r = diff+1;
  50.         }
  51.         else if(n<mid && n>=first)
  52.         {
  53.             diff = mid-n;
  54.             c = x-diff;
  55.             r = x;
  56.  
  57.         }
  58.         else
  59.         {
  60.             c = x;
  61.             r = x;
  62.         }
  63.  
  64.         if(x%2==0)
  65.         {
  66.             printf("Case %d: %lld %lld\n",j,c,r);
  67.         }
  68.         else
  69.         {
  70.             printf("Case %d: %lld %lld\n",j,r,c);
  71.         }
  72.  
  73.     }
  74.  
  75.  
  76.  
  77.     return 0;
  78. }
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement