hdu 1058
2024-08-25 16:37:35
这道题有很多种做法,但是思路大都是一样的,代码有点类似于poj2591这道题。
题意:问因子只含有2,3,5,7的第k个数是什么?
#include<stdio.h>
int f[5843],n;
int i,j,k,l;
int Min(int a,int b,int c,int d)
{
int _min = a;
if(b<_min) _min = b;
if(c<_min) _min = c;
if(d<_min) _min = d;
if(a==_min) i++;
if(b==_min) j++;
if(c==_min) k++;
if(d==_min) l++;
return _min;
}
int main()
{
i=j=k=l=1;
f[1] = 1;
for(int t=2;t<=5842;t++)
f[t] = Min(2*f[i],3*f[j],5*f[k],7*f[l]);
while(scanf("%d",&n),n)
{
if(n%100==11||n%100==12||n%100==13)
printf("The %dth humble number is %d.\n",n,f[n]);
else if(n%10==1)
printf("The %dst humble number is %d.\n",n,f[n]);
else if(n%10==2)
printf("The %dnd humble number is %d.\n",n,f[n]);
else if(n%10==3)
printf("The %drd humble number is %d.\n",n,f[n]);
else
printf("The %dth humble number is %d.\n",n,f[n]);
}
return 0;
}
最新文章
- android srudio使用HttpClient
- 打印发现function toUpperCase() { [native code] }
- java 移位运算符
- c51跑马灯
- MooseFs-分布式文件系统系列(二)之安装总结
- mac os 添加用户到组 命令
- 启动PL/SQL Developer 报字符编码不一致错误 Database character set (AL32UTF8) and Client character set (ZHS16GBK) are different. Character set conversion may cause unexpected results. Note: you can set the client
- ios开发——实用技术篇&;XML协议详解
- EasyUI datagrid 改变url属性 实现动态加载数据
- IO流--转载
- 摇滚吧HTML5!有声前端交互!(Hello, Jsonic!)
- MySQ备份常见问题
- [Python] 图像简单处理(PIL or Pillow)
- linux 每天一点点 【ubuntu16.04 】
- 1084: 开心的小明(dengdengoj)
- mybatis-generator自动生成代码工具
- Luogu 1525 【NOIP2010】关押罪犯 (贪心,并查集)
- 3.C#的访问权限修饰符
- 关于LeNet-5卷积神经网络 S2层与C3层连接的参数计算的思考???
- Eclipse修改已存在的SVN地址