| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 31 | 24 | 23 | 76.667% |
There are $N$ cities and $N$ two-way roads in Potokoland. The cities are numbered from $0$ to $N-1$. The roads are also numbered from $0$ to $N-1$. The road number $i$ connects cities $i$ and $(3 \cdot i + 7) \bmod N$, where $x \bmod N$ is the remainder from dividing $x$ by $N$.
Determine if it is possible to travel from any city to any other city using the roads. If not, find a pair of cities that are not connected.
The first line contains $N$ ($1 \le N \le 10^6$), the number of cities in Potokoland.
Output the word 'YES' if it is possible to travel from any city to any other city.
Otherwise, output the word 'NO' on the first line. On the second line, output any two cities $A$ and $B$ ($0 \le A, B \le N-1$; $A \ne B$) such that it is impossible to travel from $A$ to $B$ using the roads. If there are several possible answers, output any one of them.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 44 | $N \le 1\,000$. |
| 2 | 56 | No additional constraints. |
4
NO 0 1
The roads are $(0, 3)$, $(1, 2)$, $(2, 1)$, $(3, 0)$, as shown on the left in the figure below.
6
YES
The roads are $(0, 1)$, $(1, 4)$, $(2, 1)$, $(3, 4)$, $(4, 1)$, $(5, 4)$, as shown on the right in the figure above.