WLJ


私信TA

用户名:hputermux

访问量:14393

签 名:

等  级
排  名 595
经  验 4080
参赛次数 4
文章发表 43
年  龄 20
在职情况 学生
学  校 河南理工大学
专  业 计算机专业

  自我简介:

计算机科学与技术专业

TA的其他文章

解题思路:求最大循环长度

注意事项:

参考代码:

#include <iostream>

#include <cstdio>

using namespace std;

int main()

{

int m,n;

while(scanf("%d %d",&m,&n)!=EOF)

{

int ans = 0;

printf("%d %d",m,n);

if(m>n) swap(m,n);

for(int i=m;i<=n;i++)

{

int count = 1,k=i;

while(k!=1)

{

count++;

if(k&1)

{

k=3*k+1;

}

else

{

k=k/2;

}

}

if(count>ans)

{

ans = count;

}

}

printf(" %d\n",ans);

}

return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区