usaco 3.1 Humble Numbers

来源:互联网 发布:简单效果图制作软件 编辑:程序博客网 时间:2024/05/17 03:09

           usaco 3.1  Humble Numbers

For a given set of K prime numbers S = {p1, p2, ..., pK}, considerthe set of all numbers whose prime factors are a subset of S. This setcontains, for example, p1, p1p2, p1p1, and p1p2p3 (amongothers). This is the set of `humble numbers' for the input set S. Note: Thenumber 1 is explicitly declared not to be a humble number.

Your job is to find the Nth humble number for a given set S. Longintegers (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.

SAMPLE INPUT

4 19

2 3 5 7

SAMPLE OUTPUT

27

 

为了提高我的题解逼格,所以usaco的就用英文好了,大家Google翻译一下就好了。

 

本题大意就是求第n个满足条件的数是多少,条件就是他是必须是p1,p2....pk的集合,范围不是很大,暴力枚举就好了。

 

程序有时间放上来,现在手上没有程序,在学校题库上

1 0