http://acm.hdu.edu.cn/showproblem.php?pid=1032

View Code
#include"iostream"
using namespace std;
int i,j,Max=0;
int fun(int x,int y)
{

for(i=x; i<=y; i++)
{
int count=1;
int xx=i;
while(xx!=1)
{

if(xx%2!=0) xx=3*xx+1;
else xx=xx/2;
count
++;

}

if(count>Max) Max=count;
}
return Max;
}
int main()
{
int N,M;
while(scanf("%d %d",&N,&M)!=EOF)
{

Max
=0;
if(N>M)
{
int temp=N;
N
=M;
M
=temp;
printf(
"%d %d %d\n",M, N,fun(N,M));
}
else printf("%d %d %d\n",N,M,fun(N,M));


}
return 0;
}

相关文章:

  • 2021-10-20
  • 2022-12-23
  • 2021-05-03
  • 2021-06-04
  • 2021-08-13
  • 2021-08-07
  • 2021-10-29
  • 2021-08-16
猜你喜欢
  • 2021-11-29
  • 2021-10-13
  • 2021-06-20
  • 2021-06-08
  • 2021-10-09
  • 2021-12-06
  • 2021-04-26
相关资源
相似解决方案