Cod sursa(job #2078575)
Utilizator | Data | 29 noiembrie 2017 19:05:18 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 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;
}