아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

K Co-prime Permutation

시간 제한1초메모리 제한512 MB

요약
n과 k가 주어질 때 gcd(p_i, i) = 1인 위치가 정확히 k개인 1부터 n까지의 순열을 만들거나, 불가능하면 -1을 출력한다.
난이도

보통10점 중 7점

유형
수학, 정수론, 그리디, 구현
정답자
아직 제출이 없습니다

문제

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 kk co-prime permutation. A permutation p_1,p_2,⋯ ,p_np\_1,p\_2,\cdots,p\_n of nn is called a kk co-prime permutation of nn if there exists exactly kk integers ii such that 1≤i≤n1 \le i \le n and gcd(p_i,i)=1\text{gcd}(p\_i,i)=1, where gcd(x,y)\text{gcd}(x,y) indicates the greatest common divisor of xx and yy.

Given nn and kk, please help Kotori construct a kk co-prime permutation of nn or just report that there is no such permutation.

Recall that a permutation of nn is a sequence of length nn containing all integers from 11 to nn.

입력

There is only one test case in each test file.

The first and only line contains two integers nn and kk (1≤n≤1061 \le n \le 10^6, 0≤k≤n0 \le k \le n).

출력

Output one line containing nn integers p_1,p_2,⋯ ,p_np\_1, p\_2, \cdots, p\_n 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!

예제2

  1. 예제 1

    입력
    5 3
    
    예상 출력
    1 4 5 2 3
    
  2. 예제 2

    입력
    1 0
    
    예상 출력
    -1