Problems in Computer Science are often classified as belonging to a certain class of problems (e、
原创
2023-05-25 09:37:30
114阅读
1005继续(3n+1)猜想(25分)卡拉兹(Callatz)猜想已经在1001中给出了
原创
2022-10-26 00:04:01
18阅读
牛客
原创
2022-10-20 10:29:17
67阅读
#include<stdio.h>intmain(){intn;/输入的正整数n/intstep=0;/计算步数/scanf("%d",&n);/*输入正整数n*/for(step=0;n>1;step++){if(n%2==0)/*如果n是偶数,则除以2*/n=n/2;else/*如果n是奇数,则用3n+1除以2*/n=(3*n+1)/2;}/*结束for循环*/pri
原创
2020-12-17 17:55:22
173阅读
1098: The 3n + 1 problem时间限制: 1 Sec 内存限制: 64 MB提交: 368 解决: 148题目描述Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2
原创
2022-08-10 10:32:14
21阅读
[问题描述]考虑如下的序列生成算法:从整数 ...
转载
2019-03-12 09:42:00
46阅读
2评论
题解:简单模拟#include #include using namespace std;int main(){ int n,m,num,cnt,max,i; while(~scanf("%d %d",&m,&n)){ printf("%d %d ",m,n...
转载
2014-08-29 17:29:00
65阅读
2评论
Description
Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an a
原创
2023-09-04 14:17:12
128阅读
#include <iostream>using namespace std;int cycle(int n){ int t=1; while(n!=1) { if(n%2) n=3*n+1; else n/=2; t++; } return t;}int main(){ int i,j,k,max,m,tag; while(cin>>i>>j) { tag=0; if(i>j) { tag=1; swap(i,j); } max=1; for(k=i;k<=j;k++) { if(cycle(k)>max) m=k,max=cycle(k
转载
2011-07-17 23:54:00
69阅读
[问题描述]考虑如下的序列生成算法:从整数 ...
转载
2019-03-12 09:42:00
45阅读
2评论
先不说题,我要吐槽!!!这题太坑了,你给了1-1,000,000的范围,然后你竟然不用任何精妙的算法,直接暴力循环就能AC,然而我还以为要用什么精妙的算法,写了大半天。。。(虽然最后还没写出来,手动黑脸),原因是忘了比较i和j的大小顺序,最后气哄哄的跑去看题解,f**k,竟然真的是水题,我还是太菜狗了。
原创
2021-09-14 17:13:51
140阅读
难易程度,简单
转载
2019-12-24 09:42:00
65阅读
2评论
The 3n + 1 problemTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 51221Accepted: 16262DescriptionProblems in Computer Science are often class...
原创
2021-07-16 15:03:28
217阅读
[问题描述]考虑如下的序列生成算法:从整数 ...
转载
2019-03-12 09:42:00
44阅读
2评论
水题,直接筛一下就好。只是须要注意输出。自己学校的渣OJ 的数据范围才叫大:All integers will be less than 10,000,000 and greater than 0.跑了1.7ms。时限2ms。POJ这道题数据范围是:All integers will be less...
转载
2014-10-01 12:23:00
76阅读
2评论
这个问题并计算质数了一下相间隔似的。思想上一致。注意问题:1 i 可能 大于或等于j -- 这里上传。小心阅读题意,我没有说这个地方不能保证。需要特殊处理2 计算过程中可能溢出,的整数大于最大值,需要使用long long关于效率和时间问题:1 能够使用数组保存中间结果,这样执行快了。内存消耗大了,...
转载
2015-07-30 10:39:00
141阅读
2评论
PC/UVa IDs: 110101/100Popularity: ASuccess rate: low Level: 1测试地址:https://vjudge.net/problem/UVA-100[问题描述]考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2;如果 n 是奇数,把它乘 3 加1。用新得到的值重复上述步骤,直到 n = 1 时停止。例如,n = ...
原创
2021-08-10 10:19:05
121阅读
[问题描述]考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2;如果 n 是奇数,把它乘 3 加1。用新得到的值重复上述步骤,直到 n = 1 时停止。例如,n = 22 时该算法生成的序列是: 22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1人们猜想(没有得到证明)对于任意整数 n,该算法总能终止于 n = 1。这个猜想对于至少 1 0
原创
2022-03-24 10:43:10
181阅读
继续(3n+1)猜想 这道题里面有比较特殊的叫标志数组,存储每个数字的状态,下标是某数字,赋值1表示此数字被覆盖。 for(i=1;i<=n;i++){ scanf("%d",&n); k=a[i]; if(b[k]==1) continue; } ·int 型的数据范围是 [ -2131,231- ...
转载
2021-10-12 20:42:00
90阅读
2评论
卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题
转载
2023-03-02 09:34:06
90阅读