Cod sursa(job #2388575)
| Utilizator | Data | 26 martie 2019 10:46:56 | |
|---|---|---|---|
| Problema | Factorial | Scor | 60 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 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/2 + 1; ++i)
{
int j = i;
int c = 0;
while(j % 5 == 0)
{
++c;
j /= 5;
}
nz += (c + 1);
//cout<<i*5<<" "<<nz<<"\n";
if(nz == P)
{
out<<i*5;
return 0;
}
else if(nz > P)
{
out<<-1<<"\n";
return 0;
}
}
return 0;
}
