CF1514C Product 1 Modulo N

题目描述

#### 题目大意: 给定一个正整数 $n$ ,找到排列 $[1,2,...,n-1]$ 的最长子序列,使它满足它元素的乘积模 $n$ 意义下为 $1$ 。 注意:子序列的定义: $b$ 是 $a$ 的子序列当且仅当可以通过删去 $a$ 的若干个(可以是 $0$ 个) 元素得到 $b$ 。

输入格式

一行一个正整数 $n$ ($2 \le n \le 10^5$),意义如题所述。

输出格式

第一行一个正整数 $len$ ,表示最长子序列的长度。 第二行以升序输出子序列中的元素。 如果有多组数据,可以输出任意一个。

说明/提示

In the first example, the product of the elements is $ 6 $ which is congruent to $ 1 $ modulo $ 5 $ . The only longer subsequence is $ [1,2,3,4] $ . Its product is $ 24 $ which is congruent to $ 4 $ modulo $ 5 $ . Hence, the answer is $ [1,2,3] $ .