Created
June 21, 2020 14:23
-
-
Save hassaku63/b4a56bd8c370b712abce8154f26e5d13 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
# wrong answer... | |
import string | |
# 1千兆 + 1 | |
N = int(input()) | |
n_digits = len(str(1000000000000001)) | |
letters = string.ascii_lowercase | |
x = N - 1 | |
ans = [] | |
while True: | |
mod = x % 26 | |
ans = [ mod ] + ans | |
x = x // 26 - 1 | |
if x <= 0: | |
if ans[0] == 0: | |
ans = [0] + ans | |
break | |
# print(ans) | |
print("".join([ letters[v] for v in ans ])) |
修正
import string
# 1千兆 + 1
N = int(input())
n_digits = len(str(1000000000000001))
letters = string.ascii_lowercase
x = N
ans = []
while True:
x -= 1
mod = x % 26
x = x // 26
ans.append(mod)
if x == 0:
break
ans = ans[::-1]
print("".join([ letters[v] for v in ans ]))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
正解例