HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


147. 50553 - Divisible by m

Guest
• Review clarifications (2)

Volume problems

• 120. 50426 - Calculating Sales
• 125. 50484 - Number Of Letters
• 130. 50440 - Call Center
• 132. 50504 - School contest
• 135. 50392 - How much space
• 136. 50443 - Dajte Express
• 140. 50655 - Divisibility by 9
• 145. 50656 - Divisibility by 11
• 147. 50553 - Divisible by m
• 148. 50596 - Your Ride Is Here (US...
• 148. 50596 - Your Ride Is Here (US...
• 150. 50763 - Valid Password
• 151. 50560 - Max Distance
• 153. 50368 - Right-most non zero d...
• 155. 50379 - a^b modulus k
• 158. 50404 - Sum of Self Powers
• 160. 50546 - Average Fuel Price

Feedback

If you notice incorrect translations in Contester, please let author know.

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.


Для отправки решений необходимо выполнить вход.

www.contester.ru