Cod sursa(job #1111399)
Utilizator | Data | 18 februarie 2014 20:54:55 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{ long int p,c1;
f>>p;
if(p%6==5) g<<"-1";
else
{c1=p/6;
p=p-c1;
if(p==0) g<<"1";
else
while(c1>=5)
{
c1=c1/5;
p=p-c1;
}
g<<5*p;}
return 0;
}