#7355. [UOI 2023 II Stage] Roads of Potokolandiya

    ID: 7355 传统题 1000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P15057数学并查集2023Special JudgeUOI(乌克兰)

[UOI 2023 II Stage] Roads of Potokolandiya

[UOI 2023 II Stage] Roads of Potokolandiya

题目描述

In Potokoland, there are $n$ cities and $n$ two-way roads. The $i$-th road connects cities $i$ and $(i+i)$ (if $i+i>n$, then $i+i-n$).

For example, if n=5n=5, the roads will be (1,2)(1, 2), (2,4)(2, 4), (3,1)(3, 1), (4,3)(4, 3), and (5,5)(5, 5).

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 one integer $n$ ($1 \leq n \leq 10^6$).

输出格式

Output $\tt{YES}$ if it is possible to travel from any city to any other city.

Otherwise, output NO\tt{NO} on the first line. On the second line, output any two cities aa and bb (1≤a,b≤n1 \leq a, b \leq n; a≠ba \neq b) such that it is impossible to travel from aa to bb using the roads.

5
NO
1 5
4
YES
7
NO
1 7
8
YES

提示

(暂无提示) 标签: P15057|数学|并查集|2023|Special Judge|UOI(乌克兰)

来源

P15057|[UOI 2023 II Stage] Roads of Potokolandiya