I am trying to become a good guy, because it doesn't take money to become good. So here's a short and simple problem statement because I am a good guy! 🙂
Given two integers and , find the minimum positive value of such that is divisible by .
is defined as the -times concatenation of the integer (without leading zeroes).
Input will start an integer () denoting the number of test cases.
In each test case, two space separated integers () and () will be given.
For each test case, print the minimum positive value of in a single separate line.
If no such exists, print -1.
2 123 9 123 10
In the first test case, is divisible by 9 while 123123 and 123 are not divisible by 9. Thus 3 is the minimum possible value of for this test case.
In the second test case, can never be divisible by 10 no matter what is.
Login to submit
Let L be the length of X (number of digits). Then, f(X,K)=∑i=0K−110iLX=X∑i=0K−110iL=X10KL−110L−1f(X,...