IEMCO8C - Editorial

Problem Link :


Difficulty:
Easy-Medium
Approach :
In this problem we need to form the array using given equation till denomination is less than or equal to 10^18 and we can see that we get array of maximum size 40. As X<=10^18,so denomination more than 10^18 is of no use.
Now query can be solved using Brute force. For each query we count the number of valid combination of denomination. And since maximum array size is 40, so in worst case it can be done in O(40*40*40*Q) . So time complexity of solution is O(Q).
Solution :
Solution to the problem can be found here.

1 Like