#SP0000061. Nguyên tố hay số đối xứng? (Primes or Palindromes?)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nguyên tố hay số đối xứng? (Primes or Palindromes?)
Primes or Palindromes?
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Rikhail compares how many primes and positive decimal palindromes there are. Let count primes not exceeding , and let count positive integers not exceeding whose decimal representations read the same forward and backward, without leading zeros. Given positive integers and , find the largest positive integer such that . If a largest such integer does not exist, print the specified sentence.
Input
One line contains positive integers and , the numerator and denominator of .
Output
Print the largest valid integer . If there is no maximum, print exactly Palindromic tree is better than splay tree.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
1 1
Output
40
Explanation
For we need . At , the primes are , so . The palindromes are through , plus , giving . The final valid value is .