PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000119. Trừ lặp lại cùng một số nguyên tố (Prime Subtraction)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trừ lặp lại cùng một số nguyên tố (Prime Subtraction)
Prime Subtraction
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given two integers and with , choose one prime number and subtract that same from a nonnegative integer number of times.
Determine whether the final value can equal . You may not change between subtractions.
Input
One line containing integers and , in that order.
Output
Print YES if repeated subtraction of one fixed prime can transform into ; otherwise print NO.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
42 32
Output
YES
Explanation
The difference is . Choose the prime and subtract twice: . The same prime is used each time, so the answer is YES. If the difference were , no prime subtraction could realize it, since every prime is at least .