Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //thanks God For Every Thing!
- //contest link:
- #include<bits/stdc++.h>
- #define pi acose(-1)
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n');
- #define wow ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #define max 170000
- typedef long long int ll;
- typedef double dl;
- using namespace std;
- int main()
- {
- ll n, t, i=1;
- ll root, mid, cil, flr, row, col;
- wow
- cin>>t;
- while(t--)
- {
- cin>>n;
- root = sqrt(n);
- if(root*root==n)
- {
- if(root%2==0)
- {
- printf("Case %lld: %lld 1\n",i, root);
- i++;
- }
- else
- {
- printf("Case %d: 1 %lld\n",i, root);
- i++;
- }
- }
- else
- {
- dl nw_root;
- nw_root = sqrt(n);
- cil = ceil(nw_root);
- flr = floor(nw_root);
- mid = ((cil*cil)+((flr*flr)+1))/2;
- if(mid==n)
- {
- printf("Case %d: %lld %lld\n",i, cil, cil);
- i++;
- }
- else if(cil*cil>n && n>mid)
- {
- row = cil;
- col = (cil*cil-n+1);
- printf("Case %d: %lld %lld\n",i, col, row);
- i++;
- }
- }
- }
- i=1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement