http://codeforces.com/contest/361/problem/B

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n,k; int main()
{
while(scanf("%d%d",&n,&k)!=EOF)
{
if(n==k)
{
printf("-1\n");
continue;
}
int m=n-k;
if(m==)
{
for(int i=; i<=n; i++)
{
if(i==) printf("%d",);
else printf(" %d",i);
}
}
else if(m==)
{
for(int i=; i<=n ;i++)
{
if(i==) printf("%d",n);
else if(i==n) printf(" %d\n",);
else printf(" %d",i);
}
}
else
{
int m1=m-;
printf("%d",n-m1);
int cnt=;
int j;
for(j=; j<=n--m1; j++)
{
printf(" %d",j);
}
for(int i=j; i<=n; i++)
{
if(i==n) printf(" 1\n");
else printf(" %d",i+);
}
}
}
return ;
}

cf B. Levko and Permutation的更多相关文章

  1. CF 1141C Polycarp Restores Permutation

    Description An array of integers p1,p2,…,pnp1,p2,…,pn is called a permutation if it contains each nu ...

  2. codeforces B. Levko and Permutation 解题报告

    题目链接:http://codeforces.com/problemset/problem/361/B 题目意思:有n个数,这些数的范围是[1,n],并且每个数都是不相同的.你需要构造一个排列,使得这 ...

  3. CodeForces 361B Levko and Permutation

    题意:有n个数,这些数的范围是[1,n],并且每个数都是不相同的.你需要构造一个排列,使得这个排列上的数与它所在位置的序号的最大公约数满足 > 1,并且这些数的个数恰好满足k个,输出这样的一个排 ...

  4. cf D. Levko and Array

    http://codeforces.com/contest/361/problem/D 用二分搜索相邻两个数的差的绝对值,然后用dp记录数改变的次数.dp[i]表示在i之前改变的次数,如果|a[i]- ...

  5. cf C. Levko and Array Recovery

    http://codeforces.com/contest/361/problem/C 这道题倒着一次,然后正着一次,在正着的一次的时候判断合不合法就可以. #include <cstdio&g ...

  6. CF 360E Levko and Game——贪心

    题目:http://codeforces.com/contest/360/problem/E 官方题解与证明:http://codeforces.com/blog/entry/9529 一条可以调整的 ...

  7. CF 500B New Year Permutation

    传送门 题目大意 给你一个数列,再给你一个矩阵,矩阵的(i,j)如果为1就表示可以将i,j位置上的数交换,问任意交换之后使原数列字典序最小并输出. 解题思路 因为如果i与j能交换,j与k能交换,那么i ...

  8. HDU 4951 Multiplication table 阅读题

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4951 题意:给一个P进制的乘法表.行和列分别代表0~p-1,第i行第j*2+1和第j*2+2列代表的是第i ...

  9. CF 500 B. New Year Permutation 并查集

    User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permut ...

随机推荐

  1. html编码转换

    http://webdesign.about.com/od/localization/l/blhtmlcodes-math.htm http://www.cnblogs.com/terryglp/ar ...

  2. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApcAAAB3CAIAAADZ1fxtAAAbFElEQVR4nO2dzbHDOo6FHY9S0WqqZt

  3. Bonobos | IT桔子

    Trumaker | IT桔子 Trumaker trumaker.com

  4. JS-事件处理

    1.一个简单的单击事件: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  5. 【更新日志】售后CP更新日志

    记录一下: [售后CP更新日志] ============================================ 更新时间:[-- :] 更新内容: .版本升级,框架升级,框架升级版本3. ...

  6. Eclipse中如何安装和使用GrepCode插件

    GrepCode(GC)Eclipse插件允许Eclipse用户在Eclipse IDE中搜索由GrepCode提供的工厂类.本教程介绍如何安装和使用插件.使用Eclipse3.5(Galileo)的 ...

  7. netstat 命令详解

    netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表.实际的网络连接以及每一个网络接口设备的状态信息,在我的计算机上执行netstat后,其输出结果为:netstat命令是一 ...

  8. IO-File 文件 目录 基本操作 递归 遍历

    创建和删除 //创建文件 File file1 = new File("不存在的文件.txt");//注意,这一步并没有创建文件,只是把磁盘中的文件封装成了一个对象 System. ...

  9. DateBox( 日期输入框) 组件

    本节课重点了解 EasyUI 中 DateBox(日期输入框)组件的使用方法,这个组件依赖于 Combo(自定义下拉框)和 Calendar(日历). 一. 加载方式//class 加载方式<i ...

  10. 网页CSS2

    列表与方块 width , hight (top, bottom ,left , right)   只有在决对坐标下才起作用 下面的使用与 ol  ul list-style:none // 取消序号 ...