Pagini recente » Cod sursa (job #1377379) | Statistici Ilie Georgiana (GeorgianaIlie) | Cod sursa (job #3219181) | Cod sursa (job #2552453) | Cod sursa (job #580135)
Cod sursa(job #580135)
/*
ID: mihai_a3
PROG: humble
LANG: C++
*/
#include <fstream>
#include <algorithm>
using namespace std;
const int N=1000005,inf=2000000;
int v[103],sol[N],n,m;
ifstream in("humble.in");
ofstream out("humble.out");
void bkt(int p,long long val)
{
if (p==n+1)
{
if (sol[0]<N-2)
sol[++sol[0]]=(int)val;
return;
}
while (val<=inf)
{
bkt(p+1,val);
val*=v[p];
}
}
int main()
{
in>>n>>m;
for (int i=1;i<=n;i++)
in>>v[i];
bkt(1,1);
sort(sol+1,sol+sol[0]+1);
out<<sol[m+1]<<"\n";
return 0;
}