题库练习 Permutation Cycle
← 上一题 下一题 →

A11632 | Permutation Cycle

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

题目描述

For a permutation $P[1...\ N]$ of integers from $1$ to $N$ , function $f$ is defined as follows:

![](/uploads/acgo/image/054bc53c729a4e69_2db6a5918543.jpeg)Let $g(i)$ be the minimum positive integer $j$ such that $f(i,j)=i$ . We can show such $j$ always exists.

For given $N,A,B$ , find a permutation $P$ of integers from $1$ to $N$ such that for $1<=i<=N$ , $g(i)$ equals either $A$ or $B$ .

输入格式

The only line contains three integers $N,A,B$ ( $1<=N<=10^{6},1<=A,B<=N$ ).

输出格式

If no such permutation exists, output -1. Otherwise, output a permutation of integers from $1$ to $N$ .

输入输出样例

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