126 周赛
第三题
最后想出思路了,但没实现,同时思路也没题解那么清晰。
py
s0 = "DKER EPH VOS GOLNJ ER RKH HNG OI RKH UOPMGB CPH VOS FSQVB DLMM VOS QETH SQB"
a = "DKER EPH VOS GOLNJ UKLMH QHNGLNJ A"
b = "AB CPH VOS FSQVB DLMM VOS QHNG A"
c = "AB"
INF = int(1e18)
N = int(1e5 + 1)
length = [len(s0)] + [None] * N
for i in range(1, N + 1):
length[i] = len(a) + len(b) + len(c) + length[i-1] * 2
length[i] = min(length[i], INF)
q = int(input())
def solve(n, k):
# if k > length[n]:
# return '.'
# if n == 0:
# return s0[k - 1]
# if k <= len(a): return a[k - 1]
# k -= len(a)
# if k <= length[n-1]: return solve(n-1, k)
# k -= length[n-1]
# if k <= len(b): return b[k - 1]
# k -= len(b)
# if k <= length[n-1]: return solve(n-1, k)
# k -= length[n-1]
# return c[k - 1]
while True:
if k > length[n]:
return '.'
if n == 0:
return s0[k - 1]
if k <= len(a):
return a[k - 1]
k -= len(a)
if k <= length[n-1]:
n -= 1
continue
k -= length[n-1]
if k <= len(b):
return b[k - 1]
k -= len(b)
if k <= length[n-1]:
n -= 1
continue
k -= length[n-1]
return c[k - 1]
for _ in range(q):
n, k = list(map(int, input().split()))
print(solve(n, k), end='')