mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2025-01-23 07:04:07 +03:00
24 lines
381 B
Python
24 lines
381 B
Python
|
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))
|