hdu 1032 The 3n + 1 problem (数学)
[csharp]
//暴力求解
#include<stdio.h>
int main()
{ www.zzzyk.com
int n,m,t;
int i,max,k,c1,c2,flag;
while(scanf("%d %d",&n,&m)!=EOF)
{c2=0;flag=0;
if(n>m)
{
t=n;n=m;m=t;
flag=1;
}
for(i=n;i<=m;i++)
{c1=1;k=i;
while(k!=1)
{
if(k%2==0)
k=k/2;
else
k=3*k+1;
c1++;
}
if(c1>c2)
{
c2=c1;
}
}
if(flag==1)
{
t=n;n=m;m=t;
}
printf("%d %d %d\n",n,m,c2);
}
return 0;
}
补充:软件开发 , C# ,