Pagini recente » Cod sursa (job #1047839) | Istoria paginii runda/miercuri_ora_10.00/clasament | Cod sursa (job #2430972) | Arhiva de probleme | Cod sursa (job #2907384)
// Infoarena.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <iostream>
#include <fstream>
#include <math.h>
void main()
{
//std::cout << "Executing..." << std::endl;
std::ifstream in;
in.open("fact.in");
std::ofstream out;
out.open("fact.out");
int target = 0;
in >> target;
in.close();
if (target == 0 || target < 0) {
out << -1;
out.close();
exit(0);
}
int n5 = 0;
int n10 = 0;
int index = 5;
do {
if (n10 + n5 > target) {
out << -1;
out.close();
exit(0);
}
int current = index;
double l10 = log10(current);
if (l10 == floor(l10)) {
n10 += l10;
current = l10;
}
double log5 = log2(current) / log2(5);
if (log5 == floor(log5)) {
n5 += log5;
}
else if (current % 5 == 0) {
n5 += 1;
}
index += 5;
} while (n10 + n5 != target);
out << index - 5;
out.close();
exit(0);
}