Cod sursa(job #2142316)
| Utilizator | Data | 24 februarie 2018 22:10:20 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.72 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int pow5(int n)
{
long long s = 0;
while(n >= 5)
{
s=s + n/5;
n =n/5;
}
return s;
}
int main()
{
int a = 0;
long int c,b = 1000000000,p;
f>>p;
if(p == 0)
{
g<<1;
return 0;
}
while(a < b)
{
c = (a + b)/2;
cout<<a<<' '<<b<<'\n';
if(pow5(c) > p)
{
b = c;
}
else
{
a = c + 1;
}
}
a = a - 5;
if(pow5(a) != p)
g<<-1;
else
{
g<<a;
}
return 0;
}
