Pagini recente » Cod sursa (job #507306) | Cod sursa (job #1668417) | Cod sursa (job #127910) | Cod sursa (job #279034) | Cod sursa (job #3319161)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p, ans = -1;
fin>>p;
long long a, b, k;
a = 1;
b = 10000000000;
int last0;
while(a <= b) {
last0 = 0;
k = (a+b)/2;
while(k >= 5) {
last0 += k/5;
k /= 5;
}
k = (a+b)/2;
if(last0 == p) {
ans = k;
b = k - 1;
}else if(last0 < p) {
a = k + 1;
} else {
b = k - 1;
}
}
fout<<ans;
return 0;
}