結果
問題 |
No.2868 Another String of yuusaan
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:24:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,302 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,684 KB |
実行使用メモリ | 54,820 KB |
最終ジャッジ日時 | 2025-06-12 19:24:29 |
合計ジャッジ時間 | 1,798 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 11 |
ソースコード
import math def find_kth_char(N, K): original = "yuusaan" if N == 1: return original[K-1] # Compute M = ceil(log4(2K + 2)) if K == 0: M = 0 else: M = math.ceil(math.log(2 * K + 2, 4)) N = min(N, M) current_level = N current_k = K while current_level > 1: contributions = [] for c in original: if c in ['u', 'a']: c_contrib = (4 ** current_level - 2) // 2 else: c_contrib = 1 contributions.append(c_contrib) sum_cont = 0 found = False for i in range(len(original)): sum_cont += contributions[i] if sum_cont >= current_k: current_char = original[i] if current_char not in ['u', 'a']: return current_char else: sum_before = sum_cont - contributions[i] current_k -= sum_before current_level -= 1 found = True break if not found: return 'n' # This should not happen as per problem constraints return original[current_k - 1] # Read input N, K = map(int, input().split()) print(find_kth_char(N, K))