解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[1000000],t,s;
int fun(int x){
if(x==1) return 1;
else {int count=1;
while(x!=1){
if(x%2==0)
x/=2;
else
x=x*3+1;
count++;
}
return count;
}
}
int main(){
while(~scanf("%d%d",&t,&s)){int max=0;
int n=min(t,s);
int m=t+s-n;
for(int i=n;i<=m;i++){
if(fun(i)>max)
max=fun(i);
}
printf("%d %d %d\n",t,s,max);
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:694 |
人见人爱A+B (C语言代码)浏览:789 |
C语言训练-斐波纳契数列 (C语言代码)浏览:2826 |
C语言程序设计教程(第三版)课后习题7.2 (Java代码)浏览:686 |
震宇大神的杀毒软件 (C++代码)浏览:1117 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:906 |
WU-C语言程序设计教程(第三版)课后习题11.11 (C++代码)(想学链表的可以看看)浏览:1357 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:514 |
字符串输入输出函数 (C语言代码)浏览:2495 |
C二级辅导-公约公倍 (C语言代码)浏览:483 |