Cod sursa(job #1238324)

Utilizator vladrochianVlad Rochian vladrochian Data 6 octombrie 2014 19:11:06
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
using namespace std;

int N, sol;

ifstream fin("fact.in");
ofstream fout("fact.out");

bool Check(int val) {
	int count = 0;
	for (int fact = 5; fact <= val; fact *= 5)
		count += val / fact;
	if (count < N)
		return true;
	return false;
}

int main() {
	fin >> N;
	for (int bit = 1 << 9; bit; bit >>= 1) {
		if (Check(sol | bit))
			sol |= bit;
	}
	fout << sol + 1 << "\n";
	return 0;
}