HDU 1058 Humble Numbers
来源:互联网 发布:淘宝网投诉电话 编辑:程序博客网 时间:2024/06/10 01:50
一看就打表题。
第一次 在初始化 数组的时候出错了。 平时喜欢把 INF 初始化为 1<<30 但是这个题 可能一乘就超过了 INF
所以卡了下。 f【n】 = min(f【1~n-1】*2,3,5,7)并且 f【n】> f【n-1】。
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <cmath>#include <cstdlib>#include <string>#include <map>#include <vector>#include <set>#include <queue>#include <stack>#include <cctype>using namespace std;typedef long long LL;typedef unsigned long long ULL;#define MAXN 6000+10#define INF (1<<30)#define mod 6char s[100][100] = {"th","st","nd","rd","th","th","th","th","th","th"};LL f[MAXN];int init(){ for(int i = 0; i < MAXN; i++) f[i] = 2147483647; f[1] = 1;f[2] = 2;f[3] = 3;f[4] = 4; for(int i = 5; i <= 5842; i++){ for(int j = i-1; j >= 1; j--){ if(f[j]*7 <= f[i-1]) break; f[i] = min(f[i], f[j]*7); if(f[j]*5 > f[i-1]) f[i] = min(f[i], f[j]*5); if(f[j]*3 > f[i-1]) f[i] = min(f[i], f[j]*3); if(f[j]*2 > f[i-1]) f[i] = min(f[i], f[j]*2); } } return 1;}int main (){ init(); int n; while(scanf("%d",&n) != EOF && n){ printf("The %d%s humble number is %d.\n",n,(n%100 == 11||n%100 == 12||n%100 == 13)? s[0]:s[n%10],f[n]); } return 0;}
0 0
- HDU 1058 Humble Numbers
- hdu 1058 Humble Numbers
- hdu 1058 Humble Numbers
- HDU 1058 Humble Numbers
- hdu 1058 Humble Numbers
- HDU 1058 Humble Numbers
- hdu 1058 humble numbers
- hdu 1058 Humble Numbers
- hdu 1058 Humble Numbers
- HDU 1058 Humble Numbers
- HDU 1058 Humble Numbers
- HDU 1058 Humble Numbers
- hdu 1058 Humble Numbers
- HDU-1058 Humble Numbers
- hdu 1058 Humble Numbers
- HDU 1058 Humble Numbers
- HDU 1058 Humble Numbers
- hdu 1058 Humble Numbers
- uva125(floyd)
- POJ3320 Jessica's Reading Problem(双指针)
- Android 开源库——侧滑菜单栏(SlidingMenu)的导入和使用
- 判断NSString 是否为数字
- gps 数据解析-NMEA 0183协议
- HDU 1058 Humble Numbers
- hdu 2542 补兵(二分,模拟)
- Eclipse上搭建SSH(struts-2.2.3 + spring-2.5.6 + hibernate-3.6.8)框架-附源码
- window xp的快速启动图标全部被更改为IE浏览器图标的解决办法
- 让我们谈谈js原型链和继承
- extern "c"用法解析
- Run Book Automation - RBA系统介绍
- 终于彻底理解了Nyquist bandwidth的本质
- c# substring的用法