結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 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 sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
N = int(read())
# %%
def count_palindrome(N):
x = N // 2
y = N - x
return (x + 1) * x // 2 + (y + 1) * y // 2
# %%
def f(N, alphabets):
if N == 0:
return ''
left = 0
right = 10 ** 9
while left + 1 < right:
x = (left + right) // 2
if count_palindrome(x) <= N:
left = x
else:
right = x
x = left
S = (''.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)
maspy