Cod sursa(job #2164832)
Utilizator | Data | 13 martie 2018 09:59:21 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
long long p, n, x=0, a;
f>>p;
int OK=1;
n=0;
if (p == 0) g<<1;
else
while (p>=x)
{
n+=5;
a=n;
OK=1;
while (OK==1)
if (a%5)
{
x++;
a/=5;
}
else OK=0;
if (p==x) {g<<n; break;}
}
if (p<x) { g<<-1; }
return 0;
}