| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
找规律找规律,贴贴代码O(∩_∩)O~话说我不喜欢找规律⊙﹏⊙b汗#include <cstdio>
int main()
{
int si=1,sj=1;
int f;
while(scanf("%d",&f)!=EOF)
{
int level=1;
int row,col;
while ((level+1)*level/2 < f)++level;
if(level%2==0)
{
row=1,col=level;
int head=2;
for (int i=1,j=5;i<level/2;++i)
{
head+=j;
j+=4;
}
while(f>head++)
{
++row;
--col;
}
}
else
{
row=1,col=level;
int tail=(level+1)*level/2;
while(tail-- >f)
{
++row;
--col;
}
}
printf("TERM %d IS %d/%d\n",f,row,col);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator