結果

問題 No.701 ひとりしりとり
ユーザー FromBooskaFromBooska
提出日時 2023-04-04 11:00:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 81,564 KB
実行使用メモリ 83,784 KB
最終ジャッジ日時 2023-10-26 04:01:23
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,540 KB
testcase_01 AC 40 ms
53,540 KB
testcase_02 AC 40 ms
53,540 KB
testcase_03 AC 40 ms
53,540 KB
testcase_04 AC 41 ms
53,540 KB
testcase_05 AC 40 ms
53,540 KB
testcase_06 AC 40 ms
53,540 KB
testcase_07 AC 43 ms
53,540 KB
testcase_08 AC 44 ms
53,540 KB
testcase_09 AC 73 ms
68,656 KB
testcase_10 AC 84 ms
76,408 KB
testcase_11 AC 180 ms
83,784 KB
権限があれば一括ダウンロードができます

ソースコード

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