题解 1095: The 3n + 1 problem

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

1095: The 3n + 1 problem

摘要:解题思路:1. 循环次数:一个数按照一定的规则(即偶数除以2,奇数乘以3+1),转换后成为1所需的“步骤数”2. 题目目的:求输入x到输入y之间所有数的循环次数中最多的一个注意事项:我个人认为做这一题……

python版小白易懂解法

摘要:解题思路:#循环长度,一个数按照一定的规则转换后成为1所需的“步骤数”#题目所求,输入x到输入y之间所有数的循环长度中最大的一个注意事项:输入的两数x,y的大小不确定参考代码:while True: ……

1095: The 3n + 1 problem

摘要:```cpp #include using namespace std; int main() { int m,n,max; while(cin>>m>>n) {……

个人思路,随便看看吧

摘要:解题思路:学会列表的相关操作很重要注意事项:参考代码:def fun(n):    l1 = [n]    while n != 1:        if n % 2 == 0:           ……

The 3n + 1 problem (c++)

摘要:解题思路:真的是又长又臭参考代码:#include<iostream>using namespace std;int main(){    long long count = 1;    long l……

The 3n + 1 problem

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){    int x,y,max,a,b,rest; while(~scanf("%d %d",&a,&b)) { ……

1095: The 3n + 1 problem

摘要:解题思路:用 while() 每次接收两个数,用 for() 对两个数间所有数进行遍历,并更新最大循环长度。注意事项:测试用例里面有 num1 > num2 的,一开始完全没意识到,卡了很久。参考代码……

The 3n + 1 problem

摘要:解题思路:注意事项:参考代码:def f(x):    c=1    while x!=1:        if x%2==0:            x=x//2        else:     ……