| ||||||||||
| 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 | |||||||||
在线等,为什么wrong了,我实在是搞不定了!#include<iostream.h>
#include<stdlib.h>
void main()
{
int n=4;
int x,y;
while(n--)
{
int max=1;
cin>>x>>y;
if(x>10000||x<0||y>10000||y<0) exit(1);
cout<<x<<' '<<y<<' ';
if(x>y) { int temp=y;y=x;x=temp;}
for(int i=x;i<=y;i++)
{
int k=1,s=i;
while(s!=1)
{
if(s%2==1) s=3*s+1;
else s=s/2;
k++;
}
if(k>max) max=k;
}
cout<<max<<endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator