Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Inspired from Mongolian Informatics O. Prepared by Ibrahim Mesecan.
Divisible by 2013
Shqip
We are given a number (num) which is composed of only one digit (d). The length of the number is not known, but it's
known that the number contains only the same digit (d) and it's fully divisible by another number (m).
For example if the given digit is '1' and the number (m) is 3, the smallest number that contains only 1s as digit
and is divisible by 3 contains three 1s (111).
Question:
Write a program that is going to find the number of digits in num where the number
is perfectly divisible by m and the length of the number is the smallest.
Input specification
You will be given two integers: d and m where 1 ≤ d < 10 and 1 < m < 10000 .
Output specification
If there exists a result, give just one number that represents the number of digits in the result.
Note that there will be always a result ≤ 2000. If the length exceeds 2000,
show the message: "There is no such number"
Sample Input I
5 7
Sample Output I
6
|
Sample Input II
3 2
Sample Output II
There is no such number
|
Sample Input III
1 2013
Sample Output II
60
|
Output Explanation :
Input 1: 555555 is perfectly divisible by 7 (555555 / 7 = 79365)
Input 2: Because 3 is an odd number, no number composed of only 3s can be perfectly divisible by 2.
Input 3: The number composed of only 1s must have at least sixty 1s as digit in order to be divisible by 2013.
Для отправки решений необходимо выполнить вход.
|