[关闭]
@inkysakura 2017-04-25T19:14:37.000000Z 字数 489 阅读 1326

lightoj1008

CODE


#include <bits/stdc++.h>

using namespace std;
int ncase,t;
long long s,mid,tp;
int main()
{
        cin >> t;
        while(t--)
        {
                cin >>s;
                tp=sqrt(s);
                cout << "Case "<<++ncase << ": ";
                if(tp&1)
                {
                        if(s==tp*tp)
                        {
                                cout << 1<<' '<<tp<<endl;
                                continue;
                        }
                        mid=(tp+1)*tp+1;
                        if(s<=mid)
                                cout << tp+1-(mid-s)<<' '<<tp+1<<endl;
                        else
                                cout << tp+1<<' '<<((tp+1)*(tp+1)-s+1)<<endl;
                }
                else
                {
                        if(s==tp*tp)
                        {
                                cout << tp<<' '<<1<<endl;
                                continue;
                        }
                        mid=(tp+1)*(tp)+1;
                        if(s<=mid)
                                cout << tp+1<<' '<<tp+1-(mid-s)<<endl;
                        else
                                cout << ((tp+1)*(tp+1)-s+1)<< ' ' <<tp+1<<endl;
                }
        }
        return 0;
}
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注