Cod sursa(job #1936775)
Utilizator | Data | 23 martie 2017 13:29:08 | |
---|---|---|---|
Problema | GFact | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
using namespace std;
int p,q,n,nr=0,x;
int main()
{
ifstream f("gfact.in");
ofstream g("gfact.out");
f>>p>>q;
if (p==1) g<<1;
else if (q==1) g<<p;
else
{
n=p;
while (1)
{
x=n;
while (x%p==0)
{
nr++;
x=x/p;
}
if (nr>=q)
{
g <<n;
break;
}
n=n+p;
}
}
return 0;
}