Pagini recente » Cod sursa (job #2551381) | Cod sursa (job #23458) | Cod sursa (job #444143) | Cod sursa (job #1335626) | Cod sursa (job #585225)
Cod sursa(job #585225)
#include <fstream>
using namespace std;
bool prim(int x)
{
if (x == 2) return true;
if (x % 2 == 0) return false;
for (int i = 3; i * i <= x; i += 2)
if (x % i == 0) return false;
return true;
}
int N, K;
int X[102];
long long result = 1;
int main()
{
ifstream fin("factoriale.in");
ofstream fout("factoriale.out");
fin >> N >> K;
for (int i = 1; i <= N; ++i)
fin >> X[i];
for (int i = 2; i < 100; ++i)
if (prim(i))
{
int times = 0;
for (int j = 1; j <= N; ++j)
{
int aux = i;
while (aux <= X[j])
times += X[j] / aux,
aux *= i;
}
times = (times % K == 0 ? 0 : K - times % K);
while (times--) result *= i;
}
fout << result;
fin.close();
fout.close();
}