Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int t,row,col;
- ll s,sqr,dif,i=0;;
- cin>>t;
- while(t--){
- i++;
- cin>>s;
- sqr=ceil(sqrt(s));
- dif=sqr*sqr-s;
- if(dif<sqr){
- row=dif+1;
- col=sqr;
- }else{
- row=sqr;
- col=s-((sqr-1)*(sqr-1));
- }
- if(s%2==0)swap(row,col);
- cout<<"Case "<<i<<": "<<col<<' '<<row<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement