Posted on 2009-04-25 10:23
superman 阅读(118)
评论(0) 编辑 收藏 引用 所属分类:
USACO
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 freopen("humble.in", "r", stdin);
8 freopen("humble.out", "w", stdout);
9
10 int nhum = 0, neednhum, nprime;
11 int hum[100000], prime[100];
12
13 cin >> nprime >> neednhum;
14 for (int i = 0; i < nprime; i++)
15 cin >> prime[i];
16
17 hum[nhum++] = 1;
18
19 int pidx[100] = { 0 };
20
21 while (nhum < neednhum + 1)
22 {
23 int min = INT_MAX;
24 for (int i = 0; i < nprime; i++)
25 {
26 while (prime[i] * hum[pidx[i]] <= hum[nhum - 1])
27 pidx[i]++;
28 min <?= prime[i] * hum[pidx[i]];
29 }
30 hum[nhum++] = min;
31 }
32
33 cout << hum[neednhum] << endl;
34
35 return 0;
36 }
37