UVA_694:The Collatz Sequence
Language: C++ 4.8.2
#include<stdio.h>
int main(void)
{
long long int m, n, copy_m;
int count = ;
int number = ;
while()
{
scanf("%lld%lld", &m, &n); // uva要求用%lld读入有符号长整型
if(m < && n < )
break;
count = ;
copy_m = m;
while(m != )
{
if(m % == )
m = m / ;
else
{
m = *m + ;
if(m > n)
break;
}
count++;
}
number++;
printf("Case %d: A = %lld, limit = %lld, number of terms = %d\n", number, copy_m, n, count); // 注意输出格式,数据类型不统一的话,MingW下会出现莫名奇妙的错误。
} return ;
}
UVA_694:The Collatz Sequence的更多相关文章
- (Problem 14)Longest Collatz sequence
The following iterative sequence is defined for the set of positive integers: n n/2 (n is even) n 3n ...
- projecteuler---->problem=14----Longest Collatz sequence
title: The following iterative sequence is defined for the set of positive integers: n n/2 (n is eve ...
- UVa 694 - The Collatz Sequence
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- UVaOJ 694 - The Collatz Sequence
题目很简单,但是一开始却得到了Time Limit的结果,让人感到很诧异.仔细阅读发现,题目中有一个说明: Neither of these, A or L, is larger than 2,147 ...
- Project Euler 14 Longest Collatz sequence
题意:对于任意一个数 N ,寻找在 100,0000 之内按照规则( N 为奇数 N = N * 3 + 1 ,N 为偶数 N = N / 2 ,直到 N = 1 时的步数 )步数的最大值 思路:记忆 ...
- Project Euler Problem 14-Longest Collatz sequence
记忆化搜索来一发.没想到中间会爆int #include <bits/stdc++.h> using namespace std; const int MAXN = 1000000; in ...
- Zerojudge解题经验交流
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...
随机推荐
- oracle pl/sql远程连接过程
之前没用过oracle,现在公司用到就记录下安装过程吧.安装PL/SQL工具,安装oracle11G工具.打开PL/SQL 进行配置.
- 洛谷P5071 此时此刻的光辉
2s512M. 解:先分解质因数.考虑按照质因数大小是否大于√分类. 大于的就是一个数颜色个数,莫队即可n√m. 小于的直接枚举质因数做前缀和然后O(1)查询.总时间复杂度n(√m + σ(√V)). ...
- chrome屏蔽https广告
“设置” -> “高级” -> 系统/“打开代理设置” -> “安全” -> “受限站点” -> “添加” 好了
- mysql日常sql
重置表 truncate table david_account; 触发器 /* 商户资料更新时更新终端 */ DELIMITER | CREATE TRIGGER bankChange AFTER ...
- 在网站制作过程中发现的block和inline-block不同。
inline-block,简单来说就是在CSS中通过display:inline-block对一个对象指定inline-block属性,可以将对象呈递为内联对象,但是对象的内容作为块对象呈递.有时既希 ...
- java 判断数据类型和方法
java 判断数据类型和方法 .我从SOLR查询中获取一个数据一,已知数据类型,是string或者int 或者其他 .我有一个方法(set方法),只有一个参数,但是我不知道参数的数据类型,可能是str ...
- IO流9 --- 使用FileInputStream和FileOutputStream读写非文本文件 --- 技术搬运工(尚硅谷)
字节流读写非文本文件(图片.视频等) @Test public void test5(){ File srcFile = new File("FLAMING MOUNTAIN.JPG&quo ...
- rabbitmq启用和禁用web界面管理插件
rabbitmq默认安装启动以后,是没有开启web管理界面的,通过rabbitmq-plugins list命令可列出插件的启用和禁用状态. 使用rabbitmq-plugins enable xxx ...
- 【模板】倍增LCA [2017年5月计划 清北学堂51精英班 Day3]
P3379 [模板]最近公共祖先(LCA) 题目描述 如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先. 输入输出格式 输入格式: 第一行包含三个正整数N.M.S,分别表示树的结点个数.询 ...
- Vue Router 相关
1. 路由传参: 编程式的导航 router.push this.$router.push("home"); this.$router.push({ name: 'news', p ...