#P9632. [ICPC2020 Nanjing R] K Co-prime Permutation
[ICPC2020 Nanjing R] K Co-prime Permutation
题目描述
Kotori is very good at math (really?) and she loves playing with permutations and primes.
One day, she thinks of a special kind of permutation named . A permutation of is called a co-prime permutation of if there exists exactly integers such that and , where indicates the greatest common divisor of and .
Given and , please help Kotori construct a co-prime permutation of or just report that there is no such permutation.
Recall that a permutation of is a sequence of length containing all integers from to .
输入格式
There is only one test case in each test file.
The first and only line contains two integers and (, ).
输出格式
Output one line containing integers separated by one space, indicating the permutation satisfying the given constraints. If no such permutation exists output -1
(without quotes) instead. If there are multiple valid answers you can print any of them.
Please, DO NOT output extra spaces at the end of each line, otherwise your answer may be considered incorrect!
题目大意
题目描述
给定两个整数 和 ,构造一个 的排列 ,使得存在 个整数 满足 且 。
表示 和 的最大公约数。
输入格式
只有一组测试数据。
第一行输入两个整数 和 。
输出格式
输出一行 个整数 ,用空格分隔,表示一个满足给定的约束的排列。如果没有存在的排列则输出 -1
。如果有多个有效的答案,输出任意一个均可。
请不要在行末输出多余的空格,否则你的答案可能会被认为是错误的。
样例 #1
样例输入 #1
5 3
样例输出 #1
1 4 5 2 3
样例 #2
样例输入 #2
1 0
样例输出 #2
-1
5 3
1 4 5 2 3
1 0
-1