Mai intai trebuie sa te autentifici.
Cod sursa(job #1731755)
Utilizator | Data | 19 iulie 2016 19:47:23 | |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int n,i,nrc,x,j;
int main()
{
fin>>n;
if(n==0)
{
fout<<1;
}
else
{
for(i=5;;i+=5)
{
x=0;j=i;
while(j%5==0)
{
x++;
j/=5;
}
nrc+=x;
if(nrc>=n)
{
break;
}
}
if(nrc==n)
{
fout<<i;
}
else
{
fout<<-1;
}
}
return 0;
}