CF 106309A - Могучие Промежуточники

I can write the editorial, but the problem statement fields in your prompt are empty and this problem has a nontrivial construction/search idea.

CF 106309A - \u041c\u043e\u0433\u0443\u0447\u0438\u0435 \u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0438\u043a\u0438

Rating: -
Tags: -
Solve time: 23s
Verified: no

Solution

I can write the editorial, but the problem statement fields in your prompt are empty and this problem has a nontrivial construction/search idea. I found the statement for Codeforces Gym 106309 A, “Могучие Промежуточники”: it asks for the nth digit in the infinite concatenation of powers of a number k written in base k.

I need one clarification before producing the full editorial: should the solution target the exact original problem with input k n (2 ≤ k ≤ 36, 1 ≤ n ≤ 10^18) and output the digit, or do you have a different version of the statement?

If it is the original one, I will write the complete editorial with the derived math solution and Python implementation.