eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків

Decimal

A rational number is a number which can be expressed as a ratio of two integers. In addition, all rational numbers can be expressed as a decimal number with some repeating periodic part (in some cases the repeating part is \textbf{0}). For example \textbf{1/7 = 0.1428571428571428}... with \textbf{142857} repeating itself infinitely. Other fractions have some finite number of non-repeating digits before the periodic part begins. For example, \textbf{1/6 = 0.166666}... starts with a \textbf{1} and then settles into repeating \textbf{6}'s. Your task is to write a program that takes four int's: \textbf{lower}, \textbf{upper}, \textbf{lowerLength}, and \textbf{upperLength}. Your program must find all integers \textbf{n} between \textbf{lower} and \textbf{upper}, inclusive, where the repeating portion of the decimal representation of \textbf{1/n} has between \textbf{lowerLength} and \textbf{upperLength} digits, inclusive. You should return quantity and all of the numbers you find sorted in increasing order. \InputFile First line contains integer \textbf{lower} (\textbf{1} ≤ \textbf{lower} ≤ \textbf{1000000}). Second line contains integer \textbf{upper} (\textbf{1} ≤ \textbf{upper} ≤ \textbf{1000000}). The difference between \textbf{upper} and \textbf{lower} will be at most \textbf{100}. Third line contains integer \textbf{lowerLength} (\textbf{1} ≤ \textbf{lowerLength} ≤ \textbf{1000000}). Fourth line contains integer \textbf{upperLength} (\textbf{1 }≤ \textbf{upperLength} ≤ \textbf{1000000}). \textbf{upperLength} will be greater than or equal to \textbf{lowerLength}. \OutputFile Write on the first line of output amount of numbers you find. Write numbers in increasing order. Put one number in a line.
Ліміт часу 4 секунди
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1
10
1
1
Вихідні дані #1
9
1
2
3
4
5
6
8
9
10
Джерело Sazanka-2010, Contest #1 Saratov, 2 August 2010