Pagini recente » Cod sursa (job #1995820) | Cod sursa (job #2883758) | Cod sursa (job #2089186) | Cod sursa (job #300261) | Cod sursa (job #3131417)
#include <bits/stdc++.h>
using namespace std;
const int CMAX = 1002;
int n,k,x;
map<int, int> desc;
typedef int NrMare[CMAX];
NrMare ans;
ifstream fin("factoriale.in");
ofstream fout("factoriale.out");
void add(int x){
int d = 2;
while(x > 1){
while(x%d == 0){
desc[d]++;
x /= d;
}
d++;
if(d*d > x && x > 1){
d = x;
}
}
}
void mult(NrMare x, int n){
int transport = 0;
for(int i = 1; i <= x[0]; i++){
transport += x[i]*n;
x[i] = transport%10;
transport /= 10;
}
while(transport){
x[++x[0]] = transport%10;
transport /= 10;
}
}
int main()
{
fin >> n >> k;
for(int i = 1; i <= n; i++){
fin >> x;
for(int j = 2; j <= x; j++){
add(j);
}
}
ans[0] = ans[1] = 1;
for(auto [b, e]: desc){
if(e%k == 0){
continue;
}
for(int i = 1; i <= k-(e%k); i++){
mult(ans, b);
}
}
for(int i = ans[0]; i >= 1; i--){
fout << ans[i];
}
return 0;
}