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的更多相关文章

  1. (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 ...

  2. projecteuler----&gt;problem=14----Longest Collatz sequence

    title: The following iterative sequence is defined for the set of positive integers: n n/2 (n is eve ...

  3. UVa 694 - The Collatz Sequence

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

  4. UVaOJ 694 - The Collatz Sequence

    题目很简单,但是一开始却得到了Time Limit的结果,让人感到很诧异.仔细阅读发现,题目中有一个说明: Neither of these, A or L, is larger than 2,147 ...

  5. Project Euler 14 Longest Collatz sequence

    题意:对于任意一个数 N ,寻找在 100,0000 之内按照规则( N 为奇数 N = N * 3 + 1 ,N 为偶数 N = N / 2 ,直到 N = 1 时的步数 )步数的最大值 思路:记忆 ...

  6. Project Euler Problem 14-Longest Collatz sequence

    记忆化搜索来一发.没想到中间会爆int #include <bits/stdc++.h> using namespace std; const int MAXN = 1000000; in ...

  7. Zerojudge解题经验交流

    题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...

  8. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  9. 【索引】Volume 0. Getting Started

    AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...

随机推荐

  1. mysql load date to Hbase

    一.mysql迁移数据进hbase需要配置好配置文件 用sqoop 命令进行迁移 二. 配置文件内容: import--connectjdbc:mysql://172.18.32.99:3306/te ...

  2. join和os.path.join 的用法

    Python中有join和os.path.join()两个函数,具体作用如下: join:连接字符串数组.将字符串.元组.列表中的元素以指定的字符(分隔符)连接生成一个新的字符串os.path.joi ...

  3. 微信小程序示例

    http://www.cnblogs.com/ihardcoder/p/6097941.html http://www.wxapp-union.com/ http://blog.csdn.net/li ...

  4. HTML+JS---限制表单多次提交

    限制表单多次提交: 表单只能提交一次 function check_form_data(){ $("#once_submit").attr("disabled" ...

  5. 前端(jQuery)(2)-- JQuery选择器和事件

    1.选择器 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  6. 数组的方法之(Array.prototype.forEach() 方法)

    forEach() 方法对数组的每个元素执行一次提供的函数. 注意: 没有返回一个新数组 并且 没有返回值! 应用场景:为一些相同的元素,绑定事件处理器! const arr = ['a', 'b', ...

  7. 抓取B站小视频

    抓取B站小视频的代码如下: #请求库import requests #请求头部信息(用户代理)headers={ 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; ...

  8. css3 炫酷下拉菜单

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. MySQL数据库起步 关于数据库的基本操作(更新中...)

    mysql的基本操作 连接指定的服务器(需要服务器开启3306端口) mysql -h ip地址 -P 端口号 -u 账号 -p 密码 删除游客模式 mysql -h ip地址 -P 端口号 -u 账 ...

  10. NLog系列之NLong.config变量配置篇

    $ {cached} -  将缓存应用于另一个布局输出. $ {db-null} - 为数据库渲染DbNull $ {exception} - 通过调用Logger方法之一提供的异常信息 $ {lev ...