結果

問題 No.254 文字列の構成
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-29 23:50:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 418 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 83,968 KB
最終ジャッジ日時 2024-04-16 00:38:36
合計ジャッジ時間 7,648 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
63,616 KB
testcase_01 AC 65 ms
63,872 KB
testcase_02 AC 65 ms
63,616 KB
testcase_03 AC 69 ms
63,488 KB
testcase_04 AC 72 ms
63,616 KB
testcase_05 AC 65 ms
64,000 KB
testcase_06 AC 66 ms
63,872 KB
testcase_07 AC 66 ms
63,360 KB
testcase_08 AC 66 ms
63,488 KB
testcase_09 AC 65 ms
63,616 KB
testcase_10 AC 66 ms
63,744 KB
testcase_11 AC 67 ms
63,488 KB
testcase_12 AC 66 ms
63,744 KB
testcase_13 AC 68 ms
64,000 KB
testcase_14 AC 71 ms
67,200 KB
testcase_15 AC 85 ms
76,928 KB
testcase_16 AC 112 ms
76,928 KB
testcase_17 AC 418 ms
83,968 KB
testcase_18 AC 402 ms
83,840 KB
testcase_19 AC 350 ms
82,176 KB
testcase_20 AC 233 ms
79,488 KB
testcase_21 AC 348 ms
82,944 KB
testcase_22 AC 154 ms
77,824 KB
testcase_23 AC 211 ms
78,336 KB
testcase_24 AC 199 ms
78,336 KB
testcase_25 AC 353 ms
81,792 KB
testcase_26 AC 358 ms
81,536 KB
testcase_27 AC 321 ms
81,536 KB
testcase_28 AC 269 ms
80,000 KB
testcase_29 AC 377 ms
83,584 KB
testcase_30 AC 369 ms
82,688 KB
testcase_31 AC 140 ms
77,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from string import ascii_lowercase


def tmp(N):
    l = 0
    r = 10 ** 6
    while r - l > 1:
        m = (l + r) // 2
        M = m * 2
        if M * (M + 2) // 4 > N:
            r = m
        else:
            l = m
    return l * 2


N = int(input())
ans = ""
p, q = 0, 1

while N > 1:
    L = tmp(N)
    for i in range(L):
        if i % 2 == 0:
            ans += ascii_lowercase[p]
        else:
            ans += ascii_lowercase[q]
    N -= L * (L + 2) // 4
    p = (p + 2) % len(ascii_lowercase)
    q = (q + 2) % len(ascii_lowercase)

if N:
    ans += ascii_lowercase[p]

print(ans)
0