Pagini recente » Cod sursa (job #804761) | Cod sursa (job #1841684) | Cod sursa (job #2891849) | Cod sursa (job #2285673) | Cod sursa (job #1521168)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int get (int x)
{
int i;
x -= x % 5;
while (x) {
int a = x;
while (a % 5 == 0) { a /= 5; i++; x -= 5; }
return i;
}
int main ()
{
int p, a, b, m, k;
ifstream f("fact.in");
ofstream g("fact.out");
f >> p;
a = 1; b = 5 * p;
m = a + (b - a) / 2;
while (a <= b) {
k = get (m);
if (k == p) g << k;
if (k < p) a = m + 1;
if (k > p) b = m;
m = a + (b - a) / 2;
}
f.close ();
g.close ();
return 0;
}