1095: The 3n + 1 problem 摘要:解题思路:注意事项:参考代码:#include<stdio.h>int f(int n){ int i=1; while(n!=1) { if(n%2==0) n=n/2; else …… 题解列表 2023年11月03日 0 点赞 0 评论 155 浏览 评分:0.0
The 3n + 1 problem 摘要:解题思路:利用for循环逐个遍历输入数之间的数,计算每一个数的周期,找到最大周期即可注意事项:本题有一个坑,输入的第一个数不一定是大于第二个数的,所以需要找到输入两数中的较大值与较小值参考代码:#in…… 题解列表 2024年03月08日 0 点赞 0 评论 229 浏览 评分:0.0
1095 3n+1(递归解决) 摘要:解题思路:注意事项:参考代码:#include<stdio.h>long long digui(int n,long long m){ if(n==1)//如果是 1 ,就退出循环 { m+=1;…… 题解列表 2024年05月30日 0 点赞 0 评论 215 浏览 评分:0.0
The 3n + 1 problem,goto真好用! 摘要:解题思路:注意事项:参考代码:#include"bits/stdc++.h" using namespace std; int main(){ // 定义变量a, b, c和数组d,l用…… 题解列表 2024年11月11日 0 点赞 0 评论 203 浏览 评分:0.0
会调用函数就可以 摘要:解题思路:注意事项:注意比较输入两个数的大小参考代码:#include <stdio.h>int c(int n) { int length = 1; // 初始…… 题解列表 2025年01月12日 1 点赞 0 评论 169 浏览 评分:0.0
注意审题有陷阱,花我那么多时间 摘要:解题思路:注意事项:有可能n>m,如果用for从n到m要换位置,而且输出的时候要注意以输入时的顺序输出参考代码:#include<stdio.h>#include<string…… 题解列表 2025年02月11日 0 点赞 0 评论 184 浏览 评分:0.0
The 3n + 1 problem 摘要:解题思路:注意事项:参考代码:#include<stdio.h>int prime(int a){ int c = 0; while (a != 1) { c++; if (a % 2…… 题解列表 2025年02月26日 0 点赞 0 评论 158 浏览 评分:0.0
**你是不是也错了33%!?** 摘要::sweat_smile:杭电题的细节要求绝对是top,***注意题目上并没有说i>j。错33%就在这错着。*** ```cpp #include using namespace std; t…… 题解列表 2019年10月21日 0 点赞 0 评论 555 浏览 评分:6.0
3n+1—(c++) 摘要:解题思路: 其实这题的思路就是让他在两个数之间按照公式来回算,直到找到最大循环数,输出即可注意事项: 需要特别注意的就是两个数的数值,比如测试样例的值a和b,是1和10,我们习惯性的从1跑…… 题解列表 2022年01月13日 0 点赞 0 评论 334 浏览 评分:6.0
1095: The 3n + 1 problem(C语言版) 摘要:**题意:** 1、对于整数n,如果n是偶数,则除以2。如果n是奇数,乘以3加1,当n=1时终止。 2、输入:整数i和j 3、循环长度是指在1之前(包括1)生成的数。 3、输出:输出i和j的顺…… 题解列表 2022年02月09日 0 点赞 0 评论 383 浏览 评分:6.0