#SP0000013. Lặp lại một số (Simple Repetition)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lặp lại một số (Simple Repetition)
Simple Repetition
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Pasha constructs an integer by concatenating the decimal representation of positive integer exactly times, with no separators or leading zeroes. For instance, and produce . Determine whether is prime. The constructed integer may be very large and need not be printed.
Input
One line containing two integers and , in that order.
Output
Print YES if is prime, or NO otherwise.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
52 3
Output
NO
Explanation
Concatenating 52 three times gives , an even integer greater than . It is composite; print NO.
Input
7 1
Output
YES
Explanation
With , the new number equals , which is prime. Print YES.
Input
1 2
Output
YES
Explanation
Repeating 1 twice yields , a prime, so print YES.
Input
1 7
Output
NO
Explanation
Repeating 1 seven times gives , so the number is composite and the answer is NO.