Cod sursa(job #2001615)
Utilizator | Andrusca Robert RobertAndrusca | Data | 17 iulie 2017 11:16:50 |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
int n, i = 0, j;
in >> n;
if(n == 0)out << 1;
else
{
while(n > 0)
{
i += 5;
j = i;
while(j % 5 == 0)
{
j /= 5;
n --;
}
}
if(n < 0)out << -1;
else
out << i;
}
in.close();
out.close();
return 0;
}