P15403 [GeeksforGeeks] The mighty divisible number22312231
普及-
题目描述

Given four numbers X, Y, Z and N. Find smallest N digit Number that is divisible by all the three numbers X, Y and Z.
Example 1:
Input:
N = 2
X = 2, Y = 3, Z = 5
Output: 30
Explaination: 30 is the lcm of 2, 3 and 5
and it is a 2 digit number.
Example 2:
Input:
N = 2
X = 3, Y = 5, Z = 7
Output: -1
Explaination: There is no 2 digit number
divisible by 3, 5 and 7.
Your Task:
You do not need to read input or print anything. Your task is to complete the function minNumber() which takes the four number X, Y, Z and N as input parameters and returns the smallest N digit number divisible by X, Y and Z. If ther is no such number, return -1.
Expected Time Complexity: O(Log X)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ X, Y, Z, ≤ 1000
1 ≤ N ≤ 18

输入格式

见题面

输出格式

见题面

样例输入
N = 2 X = 2, Y = 3, Z = 5
样例输出
30