Cod sursa(job #1509594)
Utilizator | Data | 24 octombrie 2015 08:58:37 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int x[10000], y[100000];
int main()
{
long long P, x, y;
fin>>P;
x=0;
if(P==0) fout<<1;
else{
while(P>0)
{
x=x+5;
y=x;
P--;
y=y/5;
while(y%5==0)
{
y=y/5;
P--;
}
}
if(P<0) fout<<-1;
else fout<<x;
}
return 0;
}