Given two integers X and K. The task is to find smallest K-digit number divisible by X.
Note:  It is given that number of digits in X is always smaller or equal to K.
 
Example 1:
Input:
X = 6, K = 1
Output:
6
Explanation:
6 is the smallest 1 digit number
which is divisible by 6.
Example 2:
Input:
X = 5, K = 2
Output:
10
Explanation:
10 is the smallest 2 digit number
which is divisible by 5.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function smallestKDigitNum() which takes 2 Integers X and K as input and returns the answer.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= X <= 10^{5}
1 <= K <= 18

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def smallestKDigitNum(self, X, K):

        # code here

Solutions:
class Solution:

	def smallestKDigitNum(self, X, K):
		Min = pow(10, K - 1)
		if Min % X == 0:
			return Min
		else:
			return Min + X - (Min + X) % X


import math

class Solution:

	def smallestKDigitNum(self, X, K):
		min = pow(10, K - 1)
		if min % X == 0:
			return min
		else:
			return min + X - (min + X) % X


class Solution:

	def smallestKDigitNum(self, X, K):
		if K == 1:
			return X
		x = K - 1
		l = pow(10, x)
		if l % X == 0:
			return l
		l += X
		return l - l % X


class Solution:

	def smallestKDigitNum(self, X, K):
		value = 10 ** (K - 1)
		if value % X == 0:
			return value
		return value + X - value % X


class Solution:

	def smallestKDigitNum(self, X, K):
		start = 10 ** (K - 1)
		if start % X == 0:
			return start
		return start + X - start % X
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(X, K) = map(int, input().split())
		ob = Solution()
		print(ob.smallestKDigitNum(X, K))


class Solution:

	def smallestKDigitNum(self, X, K):
		k_digit_num = int('1' + '0' * (K - 1))
		rem = k_digit_num % X
		if rem != 0:
			return k_digit_num + X - rem
		else:
			return k_digit_num


class Solution:

	def smallestKDigitNum(self, X, K):
		if K == 1:
			return X
		temp = '1' + '0' * (K - 1)
		high = '9' + '9' * (K - 1)
		temp = int(temp)
		high = int(high)
		t = temp // X
		if X * t == temp:
			return temp
		else:
			return X * (t + 1)


class Solution:

	def smallestKDigitNum(self, X, K):
		t = 10 ** (K - 1)
		d = t % X
		if d != 0:
			t += X - d
		return t


class Solution:

	def smallestKDigitNum(self, X, K):
		mn = pow(10, K - 1)
		if mn % X == 0:
			return mn
		return mn + X - (mn + X) % X


class Solution:

	def smallestKDigitNum(self, X, K):
		num = 10 ** (K - 1)
		return num if num % X == 0 else num + X - num % X


class Solution:

	def smallestKDigitNum(self, x, k):
		p = 10 ** (k - 1)
		if p % x == 0:
			return p
		l = p + x - (p + x) % x
		return l