Plz explain me the code

for z in range(int(input())): a, b, k = map(int, input().split()) x = len(str(a)) p = 10**x while True: cur = p-a cur = (cur+b-1)//b if cur*x < k: k -= cur*x x += 1 p *= 10 a += cur*b else: a += b*((k-1)//x) print(str(a)[(k-1)%x]) break Bob is writing a program that solves the following problem: You are given the numbers to display the infinite sequence of numbers . Bob has made a mistake, he namely forgot to draw a space for the division between the numbers, resulting in a long line of numbers. In order not to correct the mistake, Bob decided to find out how to find the digit in the formed line (numbering of digits begins with one). Bob could not find a good solution, so he asks you for help. Input format The first line contains a number denoting the number of tests. The first line of each test contains four integers . Output format Print the digit for each test.

8th Sep 2021, 7:09 AM
Shahir - avatar
1 Answer
+ 1
23 i got you
20th Sep 2021, 9:08 AM
George Bishop
George Bishop - avatar