• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #210 Div2 B

B. Levko and Permutation
time limit per test 1 second
memory limit per test 256 megabytes

Levko loves permutations very much. A permutation of length n is a sequence of distinct positive integers, each is at most n.

Let’s assume that value gcd(a, b) shows the greatest common divisor of numbers a and b. Levko assumes that element pi of permutation p1, p2, ... , pn is good if gcd(i, pi) > 1. Levko considers a permutation beautiful, if it has exactly k good elements. Unfortunately, he doesn’t know any beautiful permutation. Your task is to help him to find at least one of them.

Input

The single line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ n).

Output

In a single line print either any beautiful permutation or -1, if such permutation doesn’t exist.

If there are multiple suitable permutations, you are allowed to print any of them.

Sample test(s)
Input
4 2
Output
2 4 3 1
Input
1 1
Output
-1
Note

In the first sample elements 4 and 3 are good because gcd(2, 4) = 2 > 1 and gcd(3, 3) = 3 > 1. Elements 2 and 1 are not good because gcd(1, 2) = 1 and gcd(4, 1) = 1. As there are exactly 2 good elements, the permutation is beautiful.

The second sample has no beautiful permutations.

 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <stack>
 4 #include <queue>
 5 #include <vector>
 6 #include <string>
 7 #include <cmath>
 8 #include <cstdio>
 9 #include <cstring>
10 #include <cstdlib>
11 #include <iostream>
12 #include <algorithm>
13 using namespace std;
14 #define maxn 10055
15 #define ll long long
16 #define mod 1000000007
17 #define INF 0x7fffffff
18 #define eps 1e-8
19 int n, m, k, sx, sy;
20 int a[maxn];
21 int main(){
22     int t;
23     //scanf("%d", &t);
24     //while (t--){
25     //memset(a, 0, sizeof a);
26     //memset(b, 0, sizeof b);
27     scanf("%d%d", &n, &m);
28     if (m == n){ printf("-1\n"); return 0; }
29     for (int i = 1; i <= n; i++){
30             if (i < n - m)printf("%d ", i + 1);
31             if (i == n - m)printf("1 ");
32             if (i>n - m)printf("%d ", i);
33         }
34         printf("\n");
35     //}
36     return 0;
37 }
View Code
posted @ 2013-11-11 15:29  HaibaraAi  阅读(115)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3