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

思路:只需要后k个数与下标一样,前n-k个数逆序输出就复合题意。

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=1e5+;
const double eps=1e-;
const double pi=acos(-);
#define ll long long
#define clc(a,b) memset(a,b,sizeof(a)) int main()
{
int n,m;
scanf("%d%d",&n,&m);
if(n==m)
{
printf("-1\n");
}
else
{
printf("%d ",n-m);
for(int i=;i<n-m;i++)
printf("%d ",i);
for(int i=n-m+;i<=n;i++)
printf("%d ",i);
}
return ;
}

CodeForces 361B Levko and Permutation的更多相关文章

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

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

  2. Codeforces 691D Swaps in Permutation

    Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Prac ...

  3. Codeforces 500B. New Year Permutation[连通性]

    B. New Year Permutation time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. codeforces 500B.New Year Permutation 解题报告

    题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...

  5. 【搜索】【并查集】Codeforces 691D Swaps in Permutation

    题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...

  6. cf B. Levko and Permutation

    http://codeforces.com/contest/361/problem/B #include <cstdio> #include <cstring> #includ ...

  7. [Codeforces 864D]Make a Permutation!

    Description Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to ...

  8. Codeforces 785E. Anton and Permutation

    题目链接:http://codeforces.com/problemset/problem/785/E 其实可以CDQ分治... 我们只要用一个数据结构支持单点修改,区间查询比一个数大(小)的数字有多 ...

  9. Codeforces 804E The same permutation(构造)

    [题目链接] http://codeforces.com/contest/804/problem/E [题目大意] 给出一个1到n的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...

随机推荐

  1. Oracle 插入数据

    6个柜面交易 打印修改--050101 delete from tran_prints where tran_id = (select id from tran where code='050101' ...

  2. 蜗牛历险记(二) Web框架(中)

    上篇简单介绍了框架所使用的Autofac,采用Autofac提供的Ioc管理整个Web项目中所有对象的生命周期,实现框架面向接口编程.接下来介绍框架的日志系统. 一.介绍之前 框架日志是否有存在的必要 ...

  3. Unity3d Shader开发(三)Pass(Fog )

    雾参数用于雾命令控制. 雾化是通过混合已生成的像素的颜色和基于到镜头的距离来确定的一个不变色来完成.雾化不会改变已经混合的像素的透明度值,只是改变RGB值. Syntax 语法 Fog { Fog C ...

  4. 树莓派2 安装mono3.0运行mvc4

    sudo apt-get updatesudo apt-get upgradesudo apt-get mono-completewget -c http://www.linuxdot.net/dow ...

  5. mvvm windows app DataBinding

    前台html 绑定(view):<div id="aa" data-win-bind="innerText:UserData.word" style=&q ...

  6. Memcache仅仅支持简单数据类型

    Memcache仅仅支持简单数据类型 ,复杂数据类型需要应用自己处理 从数据库当中取出数据[User [id=1, username=guowuxin, password=guowuxin], Use ...

  7. centos 下 yum 安装 nginx 平滑切换安装到 Tengine

    ---恢复内容开始--- 据说淘宝的Tengine很牛X,所以我们今天也来玩玩,我们这里是某开放云的vps,现在已经安装好了nginx,现在我们要平滑切换到安装Tengine. 下载Tengine,解 ...

  8. Python 学习日志(一)

    第一天: (一)安装Python3.3: (二)试运行: 1.在IDLE中输入:print("Hello,world"); //回车查看结果 2.使用"File" ...

  9. r个有标志的球放进n个不同的盒子里,要求无一空盒,问有多少种不同的分配方案?

           由题意可知道r>=n,我原来想的是先取n个全排列,剩下的r-n个每个有n中选择,所以结果是n!*n^(r-n).经满神猜测,这样是会重复的.比如说,1到5个球,ABC三个盒子,ms ...

  10. 查看java的.class文件的方法

    在不通过eclipse等IDE安装反编译插件的情况下查看java的.class文件的方法:可以通过下载jd-gui class文件查看工具进行查看.如附件的“jd-gui.exe”程序. 1. 从网上 ...