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. org.apache.ant实现压缩和解压

    <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactI ...

  2. HDFS应用实例

  3. 前端插件--swipe.js

    swipe.js的作用: 这是一个轻量级的移动滑动组件,支持触摸移动,支持响应式页面. 效果图: 代码: <!DOCTYPE html> <html lang="en&qu ...

  4. npm常用命令及版本号

    npm 包管理器的常用命令 测试环境为node>=8.1.3&&npm>=5.0.3 1, 首先是安装命令 //全局安装 npm install 模块名 -g //本地安装 ...

  5. Delphi 设计模式:《HeadFirst设计模式》Delphi7代码---命令模式之RemoteControlTest[转]

      1   2{<HeadFirst设计模式>之命令模式 }   3{ 本单元中的类为命令的接收者      }   4{ 编译工具 :Delphi7.0         }   5{ 联 ...

  6. HTML5属性

    HTML5同时增加和废除了很多属性.下面介绍一些常用的属性. 1.表单属性 为input(type=text).select.textarea与button元素新增了autofocus属性.(它以指定 ...

  7. python基础--数据类型的常用方法1

    1.数字类型 整型 用途:存qq号,手机号,不带字母的身份证号... 进制转换: 二进制转十进制:10 -->  1*(2**1) + 0*(2**0) 2 八进制转十进制:  235  --& ...

  8. 2019-4-16-C#-在-8.0-对比-string-和-string_-的类型

    title author date CreateTime categories C# 在 8.0 对比 string 和 string? 的类型 lindexi 2019-04-16 10:16:56 ...

  9. Leetcode47. Permutations II全排列2

    给定一个可包含重复数字的序列,返回所有不重复的全排列. 示例: 输入: [1,1,2] 输出: [ [1,1,2], [1,2,1], [2,1,1] ] 在全排列1题目的基础上先排序,目的是把相同的 ...

  10. 关于Ajax提交后无法刷新iframe页面的问题

    原因及解决方法: 要把刷新代码写进ajax的代码块里面,而不是放在后面