Pagini recente » Cod sursa (job #3041543) | Cod sursa (job #2544080) | Monitorul de evaluare | Cod sursa (job #302364) | Cod sursa (job #184466)
Cod sursa(job #184466)
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
int PR[25] = {2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29
, 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71
, 73 , 79 , 83 , 89 , 97};
int sol[25];
void mul(int A[], int B)
{
int i, t = 0;
for (i = 1; i <= A[0] || t; i++, t /= 10)
A[i] = (t += A[i] * B) % 10;
A[0] = i - 1;
}
int NR[700];
int main(void){
ifstream in("factoriale.in" );
ofstream out("factoriale.out");
int N,i,j,K,r,z,l;
in >> N >> K;
for (i=0;i<N;i++){
in >> j;
for (l=2;l<=j;l++){
z = l;
r = 0;
while (z!=1){
while (z%PR[r] == 0){
sol[r]++;
z /= PR[r];
}
r++;
}
}
}
NR[0] = 1;
NR[1] = 1;
for (i=0;i < 25;i++)
if (sol[i])
for (j=0;j<(K-sol[i]%K)%K;j++)
mul(NR , PR[i]);
//cin >> N;
for (i=NR[0];i>0;i--)
out << NR[i];
in.close();
out.close();
return 0;
}