C. Infinity Sequence
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given an infinite sequence of lowercase English letters built using the following pattern:
abaabaaabaaaabaaaaab ...
This sequence is constructed as follows:
- Write 1
'a' - Then write 1
'b' - Then write 2
'a's - Then write 1
'b' - Then write 3
'a's - Then write 1
'b' - Then write 4
'a's - Then write 1
'b' - And so on...
That is, you keep increasing the number of 'a's by 1 each time, and insert a single 'b' after each group of 'a's.
So the sequence starts like this:
a b a a b a a a b a a a a b a a a a a b ...
You are given a positive integer k, and you need to print the k-th character in this infinite sequence (1-based indexing).
Input
- The first line contains an integer
t(\(1 ≤ t ≤ 10^5\)) — the number of test cases. - The next
tlines each contain one integerk(\(1 ≤ k ≤ 10^{16}\)) — the position in the sequence to query.
Output
For each test case, output a single character ('a' or 'b') — the character at the k-th position of the sequence.
Sample
| Input | Output |
|---|---|
|
|
Happy New Year 2026
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 7
- Start at
- 2026-01-06 14:30
- End at
- 2026-01-06 17:15
- Duration
- 2.8 hour(s)
- Host
- Partic.
- 108