hdu1058】的更多相关文章

hdu1058 题意:当一个数只有2.3.5.7这四种质因数时(也可以一种都没有或只有其中几种),这个数就是丑数,输出第 n 个丑数是多少: 其实并没有发现hdu把这道题放在 dp 专题里的意图,我的思路就是预处理出丑数数组,然后读入 n 就直接输出第 n 个丑数.我自己又一种想法,询问翔神之后又学到了另一种做法. 我自己的生成数组的方法是:数组的第一个元素定为1,然后用优先队列,首先将2,3,5,7放入优先队列,每次从队列中取出最小的一个数,将它放入数组中,然后分别将它乘上2,3,5,7后放入…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24194    Accepted Submission(s): 10596 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numb…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17407    Accepted Submission(s): 7565 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numb…
题意:输出第n个能拆分成由,2,3,5,7中的一个或者多个组成的数: 解题思路:a[i+1]=a[i]*2;a[i+2]=a[i]*3;a[i+3]=a[i]*5;a[i+4]=a[i]*7;然后把重复的去掉就行了,可以用map标记,也可以用set存,看心情:注意1是第一个数,我也不知道为什么0.0: #include<iostream> #include<algorithm> #include<map> #include<cstdio> #define l…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14047    Accepted Submission(s): 6108 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble numb…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058 题意:求只由2,3,5,7的乘积组成的数,输出格式见output 思路:开始想打表,后来打表超时.因为数据太大了10^9,所以可以考虑用已知的2,3,5,7来推出之后的数,而不是 逐个数判断. dp思路:从1开始找2,3,5,7倍数中最小的那个,每次找一下哪个数乘了一次,那个数的指针+1: 注意:输出格式中11,12,13,不是st,nd,rd. 参考文章:https://blog.csdn.…
#include<iostream> #include<string> using namespace std; int const N = 4; int map[N] = {2,3,5,7}; int findMin(int arr[], bool flag[], int len) { int min = arr[0]; int i=0; for(i=0; i<len; i++) if(arr[i] < min) min = arr[i]; for(i=0; i<…
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.  Write a program to find and print the nth element…
Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 32718    Accepted Submission(s): 14308 Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble num…
补补弱项 全面发展.. 从最基础来 sdut1299最长上升子序 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> using namespace std; ]; ]; int main() { int i,j,k,n; cin>>n; ; i <= n ; i++) { cin>>…