Cod sursa(job #782147)
Utilizator | Data | 26 august 2012 00:00:13 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int n,p,i,x;
int main()
{
fin>>n;
if (n==0)fout<<1;
else
{
for(i=0,p=5; i<n;p+=5)
{
x=p;
while(x%5==0){i++;x/=5;}
}
if (i==n) fout<< p-5;
else fout<<-1;
}
}