NYOJ1032 【Save Princess】
来源:互联网 发布:星海牌萨克斯淘宝网 编辑:程序博客网 时间:2024/05/21 02:48
Yesterday, the princess was kidnapped by a devil. The prince has to rescue our pretty princess.
"OK, if you want to save the beautiful princess, you must answer my questions correctly."the devil says.
"No problem!".
"I’ll ask you t questions. For each question, I’ll tell you an integer n, you must tell me the i th beatuiful number. If your answer is wrong, the princess and you will all die".
"But what is the characteristic of the beautiful number?" Pince asks.
"Beautiful numbers are numbers whose only prime factors are 2, 3 or 5. The sequence
1, 2, 3, 4, 5, 6, 8, 9, 10, ... shows the first 9 beautiful numbers.
By convention, 1 is included. "
Can you help the prince to save the princess?
- 输入
- The input for each case is an integer n(1≤n≤5000) and it is terminated by a negative integer.
- 输出
- For each test case, you should print an integer which represents the i th beautiful number.
- 样例输入
23-1
- 样例输出
23
#include<iostream>#include<set>using namespace std;#define MAX 5010int main(){ set<long long>a; a.insert(1); long long num[MAX]; int index=0,data[]= {2,3,5}; while(index<MAX) { num[index]=*a.begin(); a.erase(num[index]); for(int i=0; i<3; ++i) a.insert(num[index]*data[i]); ++index; } a.clear(); int k; cin>>k; while(k>0) { cout<<num[k-1]<<endl; cin>>k; } return 0;}
0 0
- NYOJ1032 【Save Princess】
- AGU13-Save The Princess
- 4238: Save the Princess 博弈
- zstu 4240 极差 zstu oj 4238 Save the Princess
- zstu 4238 Save the Princess(2016新生赛)
- save
- Save
- save
- save
- save+
- save
- save
- save
- save
- save
- save
- save
- save
- 前端工程师应该具备的三种思维
- 配置cordova-android
- 提高JQuery性能
- mysql远程登陆和本地登陆的一些问题
- Samba CVE-2015-0240 远程代码执行漏洞利用实践
- NYOJ1032 【Save Princess】
- ubuntu12.04下建立eclipse的android开发环境相关问题
- HTML5 - html5标签的变化
- Linux系统内核概要总结
- 中国专利申请CPC客户端软件问题解决方案
- MD5 密码加密的问题
- 织梦cms在本地测试完后织如何迁移
- 浅谈JS中this的几种用法
- Android: SD卡访问及文件读写权限