結果
問題 | No.254 文字列の構成 |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:56:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 671 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,712 KB |
実行使用メモリ | 72,352 KB |
最終ジャッジ日時 | 2025-03-26 15:57:02 |
合計ジャッジ時間 | 3,806 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 WA * 4 |
ソースコード
import mathdef find_k(N):k = (int(math.isqrt(4 * N + 1)) - 1) // 2while k * (k + 1) > N:k -= 1return kdef construct_string(N):if N == 1:return 'a'if N == 4:return 'iwi'k = find_k(N)remaining = N - k * (k + 1)s = []for i in range(2 * k):s.append('a' if i % 2 == 0 else 'b')current_char = 'b' if k > 0 else 'a'next_char = 'c'for _ in range(remaining):s.append(next_char)current_char = next_charnext_char = chr(ord(current_char) + 1) if current_char != 'z' else 'c'return ''.join(s)N = int(input())print(construct_string(N))