| ||||||||||
| 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 | |||||||||
代码In Reply To:为啥就是不过呢??55555555555555555 Posted by:raidou at 2004-12-27 19:27:43 #include<iostream>
using namespace std;
int main()
{
int n,i,a,b,m;
while(scanf("%d",&n)!=EOF)
{
m=0;
for(i=1;m==0;i++)
{
if(n==(i+1)*i/2)
{
if(i%2==1)
{
a=1;
b=i;
m=1;
}
else
{
a=i;
b=1;
m=1;
}
}
if(n>(i+1)*i/2&&n<(i+1)*(i+2)/2)
{
if(i%2==1)
{
a=n-(i+1)*i/2;
b=i+2-a;
m=1;
}
else
{
b=n-(i+1)*i/2;
a=i+2-b;
m=1;
}
}
}
cout<<"TERM "<<n<<" IS "<<a<<"/"<<b<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator