Pagini recente » Cod sursa (job #835571) | Cod sursa (job #397965) | Cod sursa (job #706867) | Cod sursa (job #457986) | Cod sursa (job #364891)
Cod sursa(job #364891)
#include <fstream>
#include <cmath>
//#include <iostream>
//using namespace std;
std::ifstream fin("fact.in");
std::ofstream fout("fact.out");
long long zeros(long long p)
{
long long x = 0, s = 0, i = 0;
do
{
s = p / pow(5, ++i);
x += s;
} while (s);
return x;
}
int main(){
long long int P, p, p2, ind;
fin >> P;
p = 4 * P;
p = p - p % 5;
p2 = zeros(p);
while (p2 < P)
{
p += 5;
ind = p;
while (ind % 5 == 0)
{
ind = ind / 5;
p2++;
}
}
if (p2 > P) p = -1;
if (!P) p = 1;
fout << p; //cin >> P;
fin.close();
fout.close();
return 0;
}