HDU 1032 The 3n + 1 problem
还以为要递归推一推的
结果暴力就过了
要注意 i,j 大小
#include <iostream>
using namespace std;
int a,b;
long long cnt,n,ans;
int main()
{
while(~scanf("%d%d",&a,&b))
{
ans=;
int p=a,q=b;
if(p>q) swap(p,q);
for(int i=p;i<=q;i++)
{
cnt=;
n=i;
while()
{
cnt++;
if(n==) break;
if(n%) n=*n+;
else n/=;
}
if(cnt>ans) ans=cnt;
}
printf("%d %d %ld\n",a,b,ans);
}
}
//dp[i]=dp[3*i+1]+1;
//dp[i]=dp[i/2]+1;
HDU 1032 The 3n + 1 problem的更多相关文章
- HDU 1032 The 3n + 1 problem (这个题必须写博客)
The 3n + 1 problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 1032.The 3n + 1 problem【注意细节】【预计数据不强】【8月21】
The 3n + 1 problem Problem Description Problems in Computer Science are often classified as belongin ...
- 题解报告:hdu 1032 The 3n + 1 problem(克拉兹问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1032 Problem Description Problems in Computer Science ...
- 杭电OJ——1032 The 3n + 1 problem
The 3n + 1 problem Problem Description Problems in Computer Science are often classified as belongin ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem A: The 3n + 1 problem(水题)
Problem A: The 3n + 1 problem Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 14 Solved: 6[Submit][St ...
- UVa 100 - The 3n + 1 problem(函数循环长度)
题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...
- The 3n + 1 problem 分类: POJ 2015-06-12 17:50 11人阅读 评论(0) 收藏
The 3n + 1 problem Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 53927 Accepted: 17 ...
- uva----(100)The 3n + 1 problem
The 3n + 1 problem Background Problems in Computer Science are often classified as belonging to a ...
- 【转】UVa Problem 100 The 3n+1 problem (3n+1 问题)——(离线计算)
// The 3n+1 problem (3n+1 问题) // PC/UVa IDs: 110101/100, Popularity: A, Success rate: low Level: 1 / ...
随机推荐
- java中拼接两个数组
int a[]={1,2,3,2}; int b[]={4,2,90,8,98}; int[] d3 = new int[a.length + b.length]; System.arraycopy( ...
- 使用FMDB,libqrencode实现二维码的生成并且保存到数据库
/** * 1.首先导入第三方库FMDB和libqrencode,添加库libsqlite3.tbd
- Core Bluetooth【官方文档翻译】【02】
1.中心设备和外围设备以及它们在蓝牙通讯中的角色. 在所有的BLE( Bluetooth low energy,下文简称蓝牙4.0 )通讯中都涉及2个主要的角色:中心设备和外围设备.它是基于传统的客户 ...
- 微软ajax组件
拖个listview 然后绑定数据源,对curd选项打勾,然后拖个scriptManager进来,在拉个updatepanel进来,在updatepanel中放入个contentTemplate,吧l ...
- php 代码重用
<?php /* 21.php * 代码重用 * include() required()载入文件 * include() 如果载入文件不存在,提示警告,还可以继续执行 * required() ...
- WDLINUX (Centos5.8) 安装 bcmath
环境 centos5.8 php5.2.17 因为wdos 集成的php5.2.17为精简版,并未包含php52-bcmath扩展. 所以先下载完整php5.2.17源码包 wget -c http: ...
- JavaScript 数组操作备忘
数组的定义: 方法1. var mycars=new Array()mycars[0]="Saab"mycars[1]="Volvo"mycars[2]=&qu ...
- Razor学习(二)@Html标签
原文链接:http://blog.csdn.net/pasic/article/details/7093802 只是因为原文作者说的东西,还有很多作为基础知识的东西,我都没有掌握,所以总结在这里,蓝字 ...
- Linux下编译安装qemu和libvirt
目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 2 安装libvirt 2.1 libvirt介绍 2.2 下载libvirt 2.3 编译安装 3 ...
- windows下开发PHP扩展(无需Cygwin)
第一步:准备 1.php源码包和windows下的二进制包,以及安装Visual C++,并把Microsoft Visual Studio/Common/MSDev98/Bin的绝对路径添加到win ...