Uva 6172 Hailstone HOTPO
来源:互联网 发布:新手学淘宝开店 pdf 编辑:程序博客网 时间:2024/06/16 10:13
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4183
直接模拟就可以。也可以在一定范围内记忆化。
#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;#define INF 0x3f3f3f3f#define Maxn 100005int num[Maxn];int main(){#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin);#endif int p; int m,n; int ans; int temp; scanf(" %d",&p); memset(num,0,sizeof(num)); while(p--) { scanf(" %d %d",&m,&n); temp = n; ans = n; if(num[n] == 0) { while(n!=1) { if(n%2 == 0) { n/=2; } else { n = n*3 + 1; } ans = max(ans,n); if(n<=100000 && num[n]!=0) { ans = max(ans,num[n]); break; } } ans = max(ans,n); num[temp] = ans; } else { ans = num[temp]; } printf("%d %d\n",m,ans); } return 0;}
- Uva 6172 Hailstone HOTPO
- UVALive 6172 Hailstone HOTPO (水
- UVALive 6172|HDU 4484|Hailstone HOTPO|模拟
- hdu 4484 Hailstone HOTPO
- hdu 4484 Hailstone HOTPO (暴力)
- HDU 4484 Hailstone HOTPO (记忆化搜索)
- HDU 4484 Hailstone HOTPO (简单模拟题)
- HAILSTONE
- google,Hotpo
- hailstone.cpp
- Hailstone Sequence
- hailstone sequence
- Hailstone Sequence
- Mathematics-01 Hailstone Sequence
- 3n+1问题(Hailstone问题)
- C语言Hailstone Sequence雹石序列相关练习
- Hailstone 在32位无符号整数中最大的跳跃次数
- uva
- PHP 更新购物车数量
- 进程和进程管理
- xcode4.集锦
- android 读写SD卡文件
- 采用金字塔方法进行图像分割
- Uva 6172 Hailstone HOTPO
- Qemu-kvm的memory hotplug特性
- Oracle 常用的V$ 视图脚本
- 常用有用命令
- Virtual Box + Centos6.4
- KernelIoControl(..)在5.0和6.0的区别
- 搜索引擎----网络爬虫
- hdu 2062
- Uva 6173 B-Casting