Company: Trimble
Difficulty: medium
Debugging - K-special numbers Problem Description Write a positive integer A in decimal, without leading zeros, as its digits a_1 a_2 ... a_n , where a_1 is the leftmost digit and positions are numbered from 1 . For a given integer k , the number A is called K-special if every digit leaves the same remainder modulo k as its own position does: a_i mod k = i mod k for every position i from 1 to n . You are given k and a range [L, R] . Count how many K-special numbers lie in the range, with both ends included. Each input holds several independent queries. This task was presented as a debugging exercise: the original count_K_special_numbers code did not pass the test cases. Here you write a correct count_K_special_numbers(k, L, R) , which returns the number of K-special numbers in [L, R] . Input Format The first line contains an integer T , the number of queries. Each query then takes three lines: a line with the integer k , a line with the integer L , and a line with the integer R . Outpu