CF932C Permutation Cycle
题目描述
**【题意】:**
我们有一个序列$P$,对于任意整数$i(1 \leq i \leq N)$,满足$1 \leq P_i \leq N$。
我们定义一个函数$f$,其中$f_{i,j}$的值满足:
- 当$j=1$时,$f_{i,j}=P_i$。
- 当$j\neq 1$时,$f_{i,j}=f_{P_i,j-1}$。
我们记$G_i$表示令$f_{i,j}=i$成立的最小的$j$。我们可以证明$G_i$是一定存在的。
输入$N,A,B$。$A,B$表示$G_i$只能等于$A$或$B$。求一个可能的$P$,使得对于任意$i(1 \leq i \leq N)$,都有$f_{i,j}=i$。
输入格式
The only line contains three integers $ N,A,B $ ( $ 1
输出格式
If no such permutation exists, output -1. Otherwise, output a permutation of integers from $ 1 $ to $ N $ .
说明/提示
In the first example, $ g(1)=g(6)=g(7)=g(9)=2 $ and $ g(2)=g(3)=g(4)=g(5)=g(8)=5 $
In the second example, $ g(1)=g(2)=g(3)=1 $