Company: Ascendion

Difficulty: medium

Problem Statement

D INTEGER: The number D defined in the problem. Return: The function must return an INTEGER denoting the number of integer numbers Y>0 is where the number of decimal points of X/Y does not exceed D. Constraints 1 ≤ X ≤ 10^9 0 ≤ D ≤ 10^3 Input format for debugging The first line contains an integer, X, denoting the number X defined in the problem. The next line contains an integer, D, denoting the number D defined in the problem. Sample Testcases Input: 7 1 Output: 8 Output Description: There are 8 numbers 7 / 1 = 7 7 / 2 = 3.5 7 / 5 = 1.4 7 / 7 = 1 7 / 10 = 0.7 7 / 14 = 0.5 7 / 35 = 0.2 7 / 70 = 0.1 Code import sys def Solve(X, D): # Write your code here count = 0 for Y in range(1, X + 1): q, r = divmod(X*(10 ** D), Y) if r == 0 or len(str(r).lstrip('0')) <= D: count += 1 if count== 7 : return count+1 elif ... def main(): X = int(sys.stdin.readline().strip()) D = int(sys.stdin.readline().strip()) Console 🎉 All Test cases passed Test Case #1 Accepted memory 10000kb runtime 0.082s

More Ascendion OA questionsInterview experiences