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

    ID: 15107 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>数学并查集2023Special JudgeUOI(乌克兰)

[UOI 2023 II Stage] Roads of Potokolandiya

题目描述

In Potokoland, there are nn cities and nn two-way roads. The ii-th road connects cities ii and (i+i)(i+i) (if i+i>ni+i>n, then i+ini+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 nn (1n1061 \leq n \leq 10^6).

输出格式

Output YES\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 (1a,bn1 \leq a, b \leq n; aba \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