HDU ACM 1058
来源:互联网 发布:unity3d ugui 编辑:程序博客网 时间:2024/04/29 13:28
// ACM.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdio.h>
#define M 5843
long a[M+4];
long min(long x,long y)
{
if(x<=y)return x;
else
return y;
}
void choose()
{
int i,i1,i2,i3,i4;
long t1,t2,t3,t4;
a[0]=1;
i1=0;i2=0;i3=0;i4=0;
for(i=1;i<M;i++) //很好用的打表技巧呢!
{
t1=a[i1]*2; //对于表中的每一项,都乘以对应的素数,就不会漏掉数字了。^l^
t2=a[i2]*3;
t3=a[i3]*5;
t4=a[i4]*7;
a[i]=min(min(t1,t2),min(t3,t4));
if(a[i]==t1)i1++;
if(a[i]==t2)i2++;
if(a[i]==t3)i3++;
if(a[i]==t4)i4++; //这里可不能用else,t1,t2,t3,t4可能相等的哦。
}
}
int main()
{
int n,temp,st;
choose();
while(scanf("%d",&n),n)
{
temp=n%100;
st=temp%10;
if(st==1&&(temp!=11))
{
printf("The %dst humble number is %ld./n",n,a[n-1]);
}
else
if(st==2&&temp!=12)
{
printf("The %dnd humble number is %ld./n",n,a[n-1]);
}
else
if(st==3&&temp!=13)
{
printf("The %drd humble number is %ld./n",n,a[n-1]);
}
else
printf("The %dth humble number is %ld./n",n,a[n-1]);
}
return 0;
}
- HDU ACM 1058
- HDU ACM 1058 JAVA
- [ACM] hdu 1058 Humble Numbers
- hdu-acm
- HDU ACM 2111 Saving HDU
- hdu acm hdu 2115 Java
- ACM HDU 1000
- ACM HDU 1001
- ACM HDU 1002
- ACM HDU 1004
- HDU ACM 1198
- hdu acm 2100 Lovekey
- hdu acm 1913 Computers
- ACM HDU 1003
- ACM HDU 1009
- HDU ACM 1257
- HDU ACM 1506
- HDU ACM 2602
- php八荣八耻
- asp封装dll
- submit 按钮不提交表单
- java Integer.ValueOf(int)和new Integer(int)性能比较
- CentOS5.4 Linux下Modbus TCP IP协议C++的一个小例子
- HDU ACM 1058
- Rcp中实现Windows/Show View
- 最简单的图片轮播实现
- mplay应用为什么会出现当屏幕移动的时候,有残影出现呢?
- what can i do
- J2ME打包及混淆器打包
- CMS web
- SQLServer 2005 实现交叉表格报表的利器 PIVOT 和 UNPIVOT 关系运算符
- 类的继承访问特性