Cod sursa(job #2670415)
Utilizator | Andrei Bazavan andreibazavan | Data | 9 noiembrie 2020 20:56:52 |
---|---|---|---|
Problema | GFact | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("gfact.in");
ofstream fout("gfact.out");
unsigned long long p,q,b;
int main()
{
fin>>p>>q;
unsigned long long prim=2,cont=0,nr=0;
while(p%prim==0)
{
p/=prim;
cont++;
}
cont*=q;
nr=prim*(cont-cont/prim);
b=nr;
prim=3;
while(p>1)
{
cont=0;nr=0;
while(p%prim==0)
{
p/=prim;
cont++;
}
cont*=q;
nr=prim*(cont+cont/prim);
if(nr>b)b=nr;
prim+=2;
}
fout << b << '\n';
return 0;
}