Yet another SOD problem solution codechef

Yet another SOD problem solution codechef

Ujan is a software developer. He is developing a software that takes two integers LL and RR and outputs the count of integers in the sequence L,L+1,,R1,RL,L+1,…,R−1,R whose sum of digits (SOD) is divisible by 33.

He has developed the user interface (UI) quite easily. He is having a hard time finding the logic to solve the problem. As you are not only a good friend of Ujan but also a good problem solver, he asks you to help him out.

Can you solve the problem for your friend, Ujan?

  • The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The only line of each test case contains two integer L,RL,R.

Output Format

For each test case, print a single line containing one integer equal to the count of of integers in the sequence, whose sum of digits is divisible by 33 .

  • 1T1041≤T≤104
  • 1LR10181≤L≤R≤1018


  • Subtask 11 (100100 points): Original constraints

Yet another SOD problem solution codechef


139 141
100 1235
1000 2537
998244353 1000000007
27182818284 31415926535897

Sample Output 1 



Test case 1: The numbers are 139139140140 and 141141. Their sum of digits is 131355 and 66 respectively. So, only 141141 is the number that has its sum of digits divisible by 33

Yet another SOD problem solution codechef

Leave a Reply

Your email address will not be published. Required fields are marked *