Cod sursa(job #2510293)

Utilizator StfnutsJianu Stefanut Stfnuts Data 16 decembrie 2019 11:09:41
Problema Factorial Scor 85
Compilator py Status done
Runda Arhiva de probleme Marime 0.5 kb

max_n = 500000000
min_n = 0

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

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

#print(mid_n//5 * 5)
fo.write(str(mid_n//5 * 5))

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