Given a positive floating point number N, the task is to find the smallest integer k, such that when we multiply k with N, we get a natural number.
 
Example 1:
Input: N = "30.25"
Output: 4
Explanation: 30.25 * 4 = 321, there is no 
number less than 4 which can convert 30.25
into natural number.
Example 2:
Input: N = "5.5"
Output: 2
Explanation: 5.5 * 2 = 11, there is no number
less than 2 which can convert 5.5 into 
natural number.
 
Your Task:
You don' need to read or print anything. Your task is to complete the function findMinMultiple() which takes N as input parameter in string format and returns the minimum k such that when we multiply it with N we get a natural number.
 
Expected Time Complexity:O(c) where c is constant
Expected Space Compelxity: O(1)
 
Constraints:
1 <= N <= 1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
	def findMinMultiple(self, N):
		# Code here

Solutions:
class Solution:

	def gcd(self, a, b):
		if b == 0:
			return a
		return self.gcd(b, a % b)

	def findMinMultiple(self, N):
		l = N.split('.')
		c = len(l[1])
		d = int(l[1])
		h = 10 ** c
		return h // self.gcd(d, h)


import math

class Solution:

	def findMinMultiple(self, N):
		n = len(N)
		countafterdot = 0
		dotseen = False
		num = 0
		for i in range(n):
			if N[i] != '.':
				num = num * 10 + int(N[i]) - 0
				if dotseen == True:
					countafterdot += 1
			else:
				dotseen = True
		if dotseen == False:
			return 1
		dem = int(pow(10, countafterdot))
		return dem // math.gcd(num, dem)
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		N = input()
		ob = Solution()
		ans = ob.findMinMultiple(N)
		print(ans)