| ||||||||||
| 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 | |||||||||
555,这都不过……,哪位帮看看#include <iostream.h>
void main()
{
int a, b ,i ,num , max ,temp ;
while(cin)
{
cin >> a >> b ;
max = 0 ;
cout << a << ' ' << b ;
if ( a >b ) {temp = a ;a = b ;b = temp ;}
for( i = a ; i<=b ; i++ )
{
temp = i ;
num = 1 ;
while(temp != 1 )
{
if ( temp % 2 == 0 ) temp/=2 ;
else temp=temp*3+1 ;
num++ ;
}
if ( num > max ) max = num ;
}
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