Cod sursa(job #2079205)
Utilizator | Data | 30 noiembrie 2017 19:15:28 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int fact(int n)
{
int nr0=0;
while (n>=5)
{
nr0+=(n/=5);
}
return nr0;
}
int main()
{
int rez=0,pasi=1<<30,p;
f>>p;
while (pasi)
{
if (fact(rez+pasi)<p)
{
rez+=pasi;
}
pasi/=2;
}
rez++;
if (fact(rez)!=p) g<<-1;
else g<<rez;
return 0;
}