Cod sursa(job #1486274)
Utilizator | Data | 14 septembrie 2015 16:23:40 | |
---|---|---|---|
Problema | GFact | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream f("gfact.in");
ofstream g("gfact.out");
int s,i=1,r,x=i,p;
int Factorial(int X, int Y) {
while(X>1) { s=0,i++;
while(X%i==0) x=i,X/=i,s++;
}
Y*=s;
while(Y>0){s=p+=x;
while(s%x==0)Y--,s/=x;
}
return p;
}
int main()
{
int x,y;
f>>x>>y;
g<<Factorial(x,y);
}