Cod sursa(job #1965980)
Utilizator | Data | 14 aprilie 2017 19:55:36 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int P,N,nr,c=1;
int main()
{
fin>>P;
if (P<0) N=-1;
else if (P==0) N=1;
else
while(nr!=P)
{
while(c%5==0)
{
c/=5;
nr++;
}
N+=5;
c=N;
}
if(N>1) N-=5;
fout<<N;
return 0;
}