[Login|Register]
New post

Show post

Search forum

Read post
能帮忙看一下问题吗? [ Topic ] 2014-12-04 07:58:05 areee
#include<iostream>
using namespace std;
int main()
{
   long long a,b,c,d,e,f;
   long long i;
    int sum,sum1;
    sum=1;
   
    while(cin>>a>>b)
{    e=a;
    f=b;
    if(a>b)
    {d=a;
    a=b;
    b=d;
}
   
    sum1=0;
   
    for(c=a;c<=b;c++)
    {i=c;sum1=0;
    while(true)
    {sum1++;
     if(i==1)
     break;
     if(i%2==0)
     i=i/2;
     else
     i=i*3+1;
     
     
     }
   
     if(sum1>sum)
     sum=sum1;
}
     cout<<e<<" "<<f<<" "<<sum<<endl;}
     
     return 0;
     }
       
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.4ms with 2 query(s).