UVA 100 The 3*n+1 problem】的更多相关文章

  UVA 100 The 3*n+1 problem. 解题思路:对给定的边界m,n(m<n&&0<m,n<1 000 000);求X(m-1<X<n+1)进过操作至1的最大步数. 对m到n依次计算,比较获得最大步数. 注意:1.输入格式. 本题利用  while(scanf("%d %d",&m,&n)!=EOF)                  {                 }       2.输出与题给出相同…
题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=36  The 3n + 1 problem  Background Problems in Computer Science are often classified as belonging to a certain class of problem…
3n+1问题 PC/UVa IDs: 110101/100 Popularity: A Success rate: low Level: 1 测试地址: https://vjudge.net/problem/UVA-100 [问题描述] 考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2:如果 n 是奇数,把它乘 3 加1.用新得到的值重复上述步骤,直到 n = 1 时停止.例如,n = 22 时该算法生成的序列是: 22,11,34,17,52,26,13,40,20,1…
100 - The 3n+1 problem (3n+1 问题) /* * 100 - The 3n+1 problem (3n+1 问题) * 作者 仪冰 * QQ 974817955 * * [问题描述] * 考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2:如果 n 是奇数, * 把它乘 3 加1.用新得到的值重复上述步骤,直到 n = 1 时停止. * 例如,n = 22 时该算法生成的序列是: * 22,11,34,17,52,26,13,40,20,10,5,…
uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36 预处理,RMQ求区间最大值. 代码如下: #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using…
Description Problem D The Book-shelver's Problem Input: standard input Output: standard output Time Limit: 5 seconds Memory Limit: 32 MB You are given a collection of books, which must be shelved in a library bookcase ordered (from top to bottom in t…
挺水的模拟题,刚开始题目看错了,poj竟然过了...无奈.uva果断wa了 搞清题目意思后改了一下,过了uva. 题目要求模拟木块移动: 有n(0<n<25)快block,有5种操作: move a onto b  在将a搬到b上之前,先把a和b上的积木放回原來的位置 move a over b在将a搬到b所在的那堆积木上前,先把a上的积木放回原來的位罝 pile a onto b 将包括a本身和上方的积木一起放到b上,在放之前b上方的积木放回原来的位置 pile a over b 将包括a本…
题意: 有司机,下午路线,晚上路线各n个.给每个司机恰好分配一个下午路线和晚上路线. 给出行驶每条路线的时间,如果司机开车时间超过d,则要付加班费d×r. 问如何分配路线才能使加班费最少. 分析: 感觉上是要先排序,然后时间最长的路线配另一个时间最短的路线. 这里就严格证明一下这样贪心的正确性. 以两条路线为例,其他情况都是类似的: 不妨假设:A1≥A2,B1≤B2,水平线代表d 情况一: 如图,司机一要付加班费,司机二不用,如果我们将B1.B2交换: 因为B1≤B2,所以付给司机一的加班费不会…
1.链接地址: http://bailian.openjudge.cn/practice/1207/ http://poj.org/problem?id=1207 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In…
The 3n + 1 problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 60496   Accepted: 19218 Description Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In th…