Pagini recente » Cod sursa (job #2901759) | Cod sursa (job #1234254) | Cod sursa (job #2794131) | Cod sursa (job #162323) | Cod sursa (job #1117738)
#include<iostream>
#include<fstream>
using namespace std;
unsigned putere(unsigned a, unsigned b)
{
unsigned rez=1;
while(b>1)
{ if(b%2) { rez*=a; b--; }
a*=a; b/=2;
}
return rez*a;
}
int main()
{
unsigned p,q,ex,aux,cop,d=2,max=0,exmax;
ifstream f("gfact.in");
ofstream g("gfact.out");
f>>p; f>>q;
while(p>1)
{ ex=0;
while(p%d==0)
{ p=p/d; ex++; }
if(ex)
{ aux=putere(d,ex);
if(aux>max) { max=d; exmax=ex*q; }
}
d++;
}
aux=max;
d=0;
while(exmax>0)
{
d++;
cop=d;
while(cop%max==0)
{ exmax--;
cop=cop/max;
}
}
g<<d;
return 0;
}