Cod sursa(job #2078593)
Utilizator | Data | 29 noiembrie 2017 19:14:54 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int n)
{
int nro=0;
while(n>=5)
{
nro+=(n/=5);
}
return nro;
}
int main()
{
int r=0, pas=1<<28, p;
in>>p;
while (pas!=0)
{
if(zero(r+pas)<p)
{
r+=pas;
}
pas/=2;
}
r++;
if(zero(r)!=p)
r=-1;
out<<r;
return 0;
}