Cod sursa(job #252171)
| Utilizator | Data | 3 februarie 2009 22:52:58 | |
|---|---|---|---|
| Problema | GFact | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<fstream>
using namespace std;
ifstream f1 ("gfact.in");
ofstream f2 ("gfact.out");
int main()
{
int n,k,m[1000][2],r,c,i,j,max,b,z,x,y;
f1>>n>>k;
f1.close();
c=2;
i=0;
while (n>1)
{r=0;
while (n%c==0) {n/=c; r++;}
if (r>0) {m[i][0]=c; m[i][1]=r; i++;}
c++;}
z=i;
for (i=0; i<z; i++) m[i][1]*=k;
max=0;
for (i=0; i<z; i++)
{x=m[i][0];
y=m[i][1];
j=1;
while (y>0)
{b=x*j;
r=1;
while (j%x==0) {j/=x; r++;}
y-=r;
j++;}
if (b>max) max=b;}
f2<<max;
f2.close();
return 0;
}