Cod sursa(job #2511133)

Utilizator StfnutsJianu Stefanut Stfnuts Data 18 decembrie 2019 11:38:45
Problema Factorial Scor 75
Compilator py Status done
Runda Arhiva de probleme Marime 0.52 kb

max_n = 5000000000
min_n = 1

fi = open('fact.in','r')
fo = open('fact.out','w')

p = int(fi.read())

def zer(n):
	cz = 0
	if n == 0:
		return 1
	while n != 0:
		cz = cz + (n//5)
		n = n//5
	return cz

if p <= 0:
	sol = -1
else:
	while min_n <= max_n:
		mid_n = (max_n + min_n) / 2
		tmp_res = zer(mid_n)
		if p == tmp_res:
			sol = mid_n
			max_n = mid_n -1;
		elif p < tmp_res:
			max_n = mid_n - 1
		else:
			min_n = mid_n + 1

fo.write(str(sol))

fi.close()
fo.close()
	
	
#print(zer(a))