mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-25 13:03:44 +03:00
24 lines
381 B
Python
Vendored
24 lines
381 B
Python
Vendored
def fifth_n(n, k):
|
|
s = ""
|
|
while n:
|
|
s += str(n % 5)
|
|
n //= 5
|
|
s = s[::-1]
|
|
return s[k]
|
|
|
|
|
|
def f(n):
|
|
bin_n = bin(n)[2:]
|
|
if bin_n.count("0") % 2 == 0:
|
|
n = fifth_n(n, 0) + str(n)
|
|
else:
|
|
n = str(n) + fifth_n(n, 0)
|
|
return sum(list(map(int, bin(int(n))[2:])))
|
|
|
|
|
|
m = []
|
|
for i in range(100, 501):
|
|
m.append(f(i))
|
|
|
|
print(max(m))
|