Cod sursa(job #1124893)
Utilizator | Data | 26 februarie 2014 14:18:26 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
int s=0, p, n, t=2, w;
f>>p;
if(p==0) g<<1;
else
{
for(w=5; w<=4*p; w*=5)
s+=(4*p)/w;
t=4*p+1;
while(s<p)
{
n=t; w=0;
while(n%5==0) {n/=5; w++;}
s+=w;
t++;
}
if(s==p) g<<t-1;
else g<<-1;
}
return 0;
}