atcoder#ABC210F. [ABC210F] Coprime Solitaire
[ABC210F] Coprime Solitaire
Score : points
Problem Statement
We have cards arranged in a row on a table. For each , the -th card has an integer written on the front and an integer written on the back. Initially, every card is placed face up.
Takahashi will choose any number of cards he likes (possibly zero) and flip them. Then, he will be happy if the following condition is satisfied:
- for every pair of integers such that , the integers visible on the -th and -th cards are coprime.
Determine whether it is possible for Takahashi to be happy.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible for Takahashi to be happy, print Yes
; otherwise, print No
.
3
2 5
10 9
4 8
Yes
Initially, we see integers , , and .
If we flip the first and second cards, we will see , , and , which will make Takahashi happy. Thus, we should print Yes
.
2
10 100
1000 10000
No
There is no way to flip cards to make Takahashi happy, so we should print No
.