結果

問題 No.327 アルファベット列
ユーザー AT274_
提出日時 2019-10-27 11:02:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-14 21:01:24
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 24 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input()) + 1
alphabets = [chr(i) for i in range(ord('A'), ord('A') + 26)]

if N < 26:
    print(alphabets[N - 1])
    exit()


def encode_x_base(n, x):
    if n == 0:
        return [0]

    ret = []
    while n:
        ret.append(n % x)
        n //= x

    return ret[::-1]


encoded_N_26_based = encode_x_base(N // 26, 26)
ans = [alphabets[i - 1] for i in encoded_N_26_based] + [alphabets[N % 26 - 1]]
print(''.join(ans))
0