結果
問題 | No.254 文字列の構成 |
ユーザー |
![]() |
提出日時 | 2020-03-04 14:17:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 742 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-14 00:14:10 |
合計ジャッジ時間 | 2,452 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#!/usr/bin/env python3# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlines# %%N = int(read())# %%def count_palindrome(N):x = N // 2y = N - xreturn (x + 1) * x // 2 + (y + 1) * y // 2# %%def f(N, alphabets):if N == 0:return ''left = 0right = 10 ** 9while left + 1 < right:x = (left + right) // 2if count_palindrome(x) <= N:left = xelse:right = xx = leftS = (''.join(alphabets[:2])) * (x // 2 + 5)return S[:x] + f(N - count_palindrome(x), alphabets[2:])# %%alphabets = [chr(ord('a') + x) for x in range(26)]answer = f(N, alphabets)print(answer)