Cod sursa(job #1447048)
Utilizator | Data | 3 iunie 2015 14:58:00 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
int p,i,n=0,k=0,x,j;
f>>p;
if(p==0)
g<<"1";
else
{
while (k<p)
{
n=n+5;
x=n;
j=0;
while(x%5==0)
{
j++;
x=x/5;
}
if (k+j==p) g<<n;
else if(k+j>p) g<<-1;
k=k+j;
}
}
return 0;
}