Cod sursa(job #2873102)

Utilizator stefR2020StefanRadulescu stefR2020 Data 18 martie 2022 17:35:06
Problema Factoriale Scor 20
Compilator cpp-64 Status done
Runda concursceva1 Marime 1 kb
#include <fstream>

using namespace std;
int v[105];
bool ciur[105];
int obez[]={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,100};
int put[]={6,4,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
int ok=0;
int main()
{
    ifstream cin("factoriale.in");
    ofstream cout("factoriale.out");
    while(obez[ok++]!=100)
    {
        ciur[obez[ok-1]]=1;
    }
    int n,k,x,sum=1;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        ok=23;
        while(ok>0)
        {
            for(int j=1;j<=put[obez[ok]];j++)
            {
                v[obez[ok]]+=x/(obez[ok]*j);
            }
            ok--;
        }
    }
    for(int i=2;i<=100;i++)
    {
        if((v[i]%k)!=0)
        {
            int aux=k-v[i]%k;
            while(aux>0)
            {
                sum*=i;
                aux--;
            }
        }
    }
    cout<<sum;
    return 0;
}