Cod sursa(job #855660)
Utilizator | Data | 15 ianuarie 2013 13:59:02 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <fstream>
using namespace std;
int fiv(int n)
{
int x=0;
while (n!=1)
{
n/=5;
x++;
}
return x;
}
int main()
{
long long int n=0,p,x=0;
ifstream f1("fact.in");
ofstream f2("fact.out");
f1>>p;
if (p==0) f2<<"1";
else
{
while (x<p)
{
n+=5;
x+=fiv(5);
}
if (x==p) f2<<n;
else f2<<"-1";
}
return 0;
}