結果

問題 No.701 ひとりしりとり
ユーザー FromBooska
提出日時 2023-04-04 11:00:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 83,776 KB
最終ジャッジ日時 2024-09-25 11:52:31
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

# 26**4 > 10**5なのでa????aをn-1回やって、最後はanとして終わらせる
# ????は26進法のイメージ

alphabets = 'abcdefghijklmnopqrstuvwxyz'

def Dec_to_N(num, base):
    if num >= base:
        yield from Dec_to_N(num // base, base)
    yield num % base

N = int(input())
words = []
for i in range(N-1):
    num26 = list(Dec_to_N(i, 26))
    word26 = 'a'
    for n in num26:
        word26 += alphabets[n]
    word26 += 'a'
    words.append(word26)
    #print(i, num26)
    
words.append('an')

for w in words:
    print(w)
0