Cod sursa(job #287747)
Utilizator | Data | 25 martie 2009 09:11:32 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
int p,n=0;
ifstream fin("fact.in");
fin>>p;
fin.close();
ofstream fout("fact.out");
if(p==0)n=1;
while(p)
{
n+=5;
p--;
if(n/25<5)p-=2;
if(n/125<5)p-=3;
if(n/625<5)p-=4;
if(n/3125<5)p-=5;
}
if(p<0)n=-1;
fout<<n;
fout.close();
return 0;
}