Pagini recente » Statistici Teodoreanu Florin-Nicolae (demiurg94) | Istoria paginii utilizator/sandrino | Monitorul de evaluare | Rating Birsasteanu Bogdan (BirsasteanuBogdan) | Cod sursa (job #2142246)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int pow5(int n)
{
long long s = 0;
if(n >= 5)
{
s+=n/5;
n/=5;
}
return s;
}
int main()
{
int a = 1,n,s,d;
long int c,b = 100000000,p;
f>>p;
if(p == 0)
{
g<<1;
return 0;
}
while(a <= b)
{
c = (a + b)/2;
if(pow5(c) >= p)
{
b = c - 1;
}
else
{
a = c + 1;
}
}
if(pow5(c) != p)
g<<-1;
else
g<<a-5;
return 0;
}