PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000055. Nguyên tố chữ số (Digit Primes)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nguyên tố chữ số (Digit Primes)
Digit Primes
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer is a digit prime if it is prime and the sum of its decimal digits is also prime. For example, qualifies because and are prime, whereas does not because is not prime. Given , count digit primes in the inclusive interval . Both endpoints are included.
Input
One line contains the two integers , in that order.
Output
Print one integer: the number of digit primes in .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
10 100
Output
10
Explanation
The digit primes in are . For instance, qualifies because is prime, while fails because is composite. There are exactly qualifying numbers, so the answer is 10.