题库练习 Prefix Product Sequence
← 上一题 下一题 →

A9744 | Prefix Product Sequence

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Consider a sequence $\[a_{1},a_{2},... ,a_{n}\]$ . Define its prefix product sequence ![](/uploads/acgo/image/d75e99f76b55bd6e_9a42a46e31a0.jpeg).

Now given $n$ , find a permutation of $\[1,2,...,n\]$ , such that its prefix product sequence is a permutation of $\[0,1,...,n-1\]$ .

输入格式

The only input line contains an integer $n$ ( $1<=n<=10^{5}$ ).

输出格式

Consider a sequence $\[a_{1},a_{2},... ,a_{n}\]$ . Define its prefix product sequence ![](/uploads/acgo/image/8738789450c5f84d_064d6642afdf.jpeg).

Now given $n$ , find a permutation of $\[1,2,...,n\]$ , such that its prefix product sequence is a permutation of $\[0,1,...,n-1\]$ .

输入输出样例

输入 #1
7
输出 #1
YES
1
4
3
6
5
2
7
输入 #2
6
输出 #2
NO
C++ 编辑器
输入
输出