#GL0000350. Đếm số đẹp trong đoạn (Beautiful Numbers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm số đẹp trong đoạn (Beautiful Numbers)
Beautiful Numbers
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer is beautiful if it is divisible by every nonzero decimal digit appearing in its own representation. Digit 0 imposes no condition.
For example, is beautiful because it is divisible by and ; the zero digit imposes no condition. The number is also beautiful because it is divisible by , , and . In contrast, is not beautiful because it is not divisible by its digit .
Given , count the beautiful integers in the inclusive interval .
PHOJ adaptation: one interval per input file instead of the multiple-range wrapper in the original statement.
Input
One line contains integers .
Output
Print the exact count in , without modulo.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
1 9
Output
9
Explanation
Every one-digit positive integer is divisible by its only nonzero digit, so all nine are beautiful.
Example 2
Input
12 15
Output
2
Explanation
Only 12 and 15 qualify. The value 13 is not divisible by digit 3, and 14 is not divisible by digit 4.