Cod sursa(job #1928077)
Utilizator | Data | 15 martie 2017 20:36:34 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
int p,k=0;
f>>p;
if (p==0) {g<<1;return 0;}
while (p>0)
{
k+=5;
int s=0;
int inloc=k;
while (inloc%5==0&&inloc>0)
{
s++;
inloc/=5;
}
p-=s;
}
if (p<0) g<<-1;
else g<<k;
return 0;
}