Cod sursa(job #2388587)
| Utilizator | Data | 26 martie 2019 10:57:42 | |
|---|---|---|---|
| Problema | Factorial | Scor | 60 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
int P;
in>>P;
if(P == 0)
{
out<<1;
return 0;
}
int nz = 0;
for(int i = 1; i <= 100000000/3 + 1; ++i)
{
int j = i;
int c = 0;
while(j % 5 == 0)
{
++c;
j /= 5;
}
nz += (c + 1);
if(nz == P)
{
out<<i*5;
return 0;
}
else if(nz > P)
{
out<<-1<<"\n";
return 0;
}
}
return 0;
}
