课堂学习——Beautiful number
来源:互联网 发布:软件导刊怎么样 编辑:程序博客网 时间:2024/05/17 02:24
It is not ugly number
Time Limit:2000MS Memory Limit:65535K
描述
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ...shows the
first 10 ugly numbers. By convention, 1 is included. Then, here are the first 10 Not ugly numbers:7, 11, 13, 14, 17, 19,
21, 22, 23, 26. Given the integer n, write a program to find and print the n'th Not ugly number.
输入格式
First line is T(T<=10000), the number of cases.
The T lines following. Each line of the input contains a positive integer n (n <= 100000000).
输出格式
For each case, output the n'th Not ugly number .
输入样例
3
1
2
9
输出样例
7
11
23
#include <iostream>#include <queue>#include <vector>#include <cstdio>using namespace std;typedef pair<unsigned long ,int> node_type;int main(){ unsigned long result[1700]; priority_queue<node_type,vector<node_type>,greater<node_type> >Q; Q.push(node_type(1,2)); for(int i=0;i<1700;++i) { node_type node=Q.top(); Q.pop(); switch(node.second){ case 2: Q.push(make_pair(node.first*2,2)); case 3: Q.push(make_pair(node.first*3,3)); case 5: Q.push(make_pair(node.first*5,5)); } result[i]=node.first; } int T,n,i; scanf("%d",&T); while(T--){ scanf("%d",&n); for(i=0;i<1700;++i) { if(result[i]-i-1>=n) { printf("%d\n",n+i); break; } } } return 0;}
0 0
- 课堂学习——Beautiful number
- HDU——5062 Beautiful Palindrome Number
- BC#31.1002beautiful number——数位DP/暴力
- HDU 5062 Beautiful Palindrome Number——BestCoder Round #13
- hdu5062——Beautiful Palindrome Number(模拟)
- 课堂学习——巡逻的士兵
- 课堂学习——HDUOJ-1215
- 课堂学习——HDUOJ-1452
- ZOJ 2829 Beautiful Number
- Number is beautiful
- zoj 2829 Beautiful Number
- Codeforces_394B_Very Beautiful Number(数论)
- hdu5179---beautiful number
- hdu(5179):beautiful number
- hdu5179 beautiful number
- hdu 5179-beautiful number
- ZOJ 2829 Beautiful Number
- ZOJ 2829 Beautiful Number
- C++ const用法 尽可能使用const
- 电子商务网站测试总结
- 《精彩绝伦的CSS》——布局(四)清除浮动
- Apache Cassandra架构理解
- Java实现直接插入排序算法
- 课堂学习——Beautiful number
- 面试总结(2):线程同步
- 曾经有一次机会,是阿里,没抓住!
- POJ1269-Intersecting Lines(求两直线交点)
- php-fpm 启动后没有监听端口9000
- 微信小程序之商品属性分类 —— 微信小程序实战商城系列(4)
- 从互联网到人工智能,BAT这七年来到底做了什么
- rhel系统延迟及定时机制
- 海思3516A 交叉编译安装 zlib