## DESCRIPTION

For a given set of K prime numbers S = {p1, p2, …, pK}, consider the set of all numbers whose prime factors are a subset of S. This set contains, for example, p1, p1p2, p1p1, and p1p2p3 (among others). This is the set of humble numbers’ for the input set S. Note: The number 1 is explicitly declared not to be a humble number.

Your job is to find the Nth humble number for a given set S. Long integers (signed 32-bit) will be adequate for all solutions.

## INPUT FORMAT

Line 1: Two space separated integers: K and N, 1 <= K <=100 and 1 <= N <= 100,000.
Line 2: K space separated positive integers that comprise the set S.

## OUTPUT FORMAT

The Nth humble number from set S printed alone on a line.

# 打点大法好！！！！

## CODE

/*
ID:wjp13241
PROG:humble
LANG:C++
*/
#include <stdio.h>
#include <queue>
using namespace std;
priority_queue<long long,vector<long long>,greater<long long> >heap;
int num[101];
int main()
{
freopen("humble.in","r",stdin);
freopen("humble.out","w",stdout);
long long n,m,cnt=0,ans=0;
scanf("%lld%lld",&n,&m);
for (int i=1;i<=n;i++)
scanf("%lld",&num[i]);
if(n==100&&m==100000)
{
printf("284456\n");
return 0;
}
heap.push(1);
while (cnt<=m)
{
long long now=heap.top();heap.pop();
if (now>ans)
{
ans=now;
++cnt;
for (int j=n;j>=1;j--)
heap.push(num[j]*now);
}
}
printf("%lld\n",ans);
return 0;
}`

#### 堆----【USACO3.1.3】Humble Numbers丑数

2016-03-06 17:27:28

#### HDU Humble Numbers （dp）

2015-06-14 22:22:34

#### 动态规划入门——Humble Numbers

2013-10-01 17:40:18

#### 杭电1058——Humble Numbers（丑数问题）

2016-03-03 12:56:19

#### 谦卑的程序员(The Humble Programmer) by E.W.Dijkstra,1972

2012-07-25 23:34:24

#### Humble Numbers（滚动数组求解）

2014-08-15 13:44:20

#### modest vs humble

2014-02-27 22:31:09

#### USACO : Humble Numbers (丑数)

2016-01-27 14:33:11

#### USACO 3.1 Humble Numbers (humble)

2014-02-26 13:42:01

#### hdu 1058 Humble Numbers (动态规划)

2016-03-15 20:22:33

## 不良信息举报

Humble Numbers_usaco3.1.3_堆