Last active
March 9, 2020 10:54
-
-
Save c-yan/00d6f1daceb4c2bfd158d3a865694722 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ls(L): | |
L = int(L, 2) | |
result = 0 | |
for a in range(L + 1): | |
for b in range(L + 1): | |
if a + b > L: | |
continue | |
if a + b != a ^ b: | |
continue | |
result += 1 | |
return result | |
def hs(L): | |
result = 1 | |
t = 1 | |
for c in L[::-1]: | |
if c == '1': | |
result = result * 2 + t | |
result %= 1000000007 | |
t *= 3 | |
t %= 1000000007 | |
return result | |
L = input() | |
for i in range(1, len(L) + 1): | |
s = L[-i:] | |
if s[0] == '0': | |
continue | |
print(s, ls(s), hs(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment