CodeForces 361B Levko and Permutation
题意:有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的更多相关文章
- codeforces B. Levko and Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/361/B 题目意思:有n个数,这些数的范围是[1,n],并且每个数都是不相同的.你需要构造一个排列,使得这 ...
- Codeforces 691D Swaps in Permutation
Time Limit:5000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Prac ...
- Codeforces 500B. New Year Permutation[连通性]
B. New Year Permutation time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- 【搜索】【并查集】Codeforces 691D Swaps in Permutation
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
- cf B. Levko and Permutation
http://codeforces.com/contest/361/problem/B #include <cstdio> #include <cstring> #includ ...
- [Codeforces 864D]Make a Permutation!
Description Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to ...
- Codeforces 785E. Anton and Permutation
题目链接:http://codeforces.com/problemset/problem/785/E 其实可以CDQ分治... 我们只要用一个数据结构支持单点修改,区间查询比一个数大(小)的数字有多 ...
- Codeforces 804E The same permutation(构造)
[题目链接] http://codeforces.com/contest/804/problem/E [题目大意] 给出一个1到n的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...
随机推荐
- ecshop会员中心增加订单搜索功能
在user.php中的act=order_list中增加以下程序. $order_sn = isset($_REQUEST['order_sn'])?$_REQUEST['order_sn']:''; ...
- MVC-各种传值方式
[转自]:QLeelulu示例一:ViewData传值.HomeController.cs Co de: public ActionResult Index(){ ViewData[" ...
- Codeforces 612E - Square Root of Permutation
E. Square Root of Permutation A permutation of length n is an array containing each integer from 1 t ...
- C语言小知识
1.数组初始化 a[5] = {1}; //1,0,0,0,0 a[5] = {0}; //0,0,0,0,0 a[3][3] = {1}; //1,0,0;0,0,0;0,0,0 a[3][ ...
- windows azure tools for mac
http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/?fb=zh-cn http://www.windowsazure. ...
- 通过xib文件创建和连接UIView
使用Xcode写程序,时间长了,对于界面上的元素,很多时候不想手写代码进行构建,但是有些UIView里面的子控件,又不能通过xib直接进行构造,要是总使用UIViewController来结合xib进 ...
- Ubuntu使用apt-get安装本地deb包
我们都喜欢使用apt-get,因为它实在是让我们大大的省心.但是,有时候我们会为网速慢,安装源不好而烦恼,所以我们可能会将一些常用软件包的deb文件保存在本地以备不时之需.当然了使用dpkg也可以直接 ...
- 练习--LINUX进程间通信之消息队列MSG
https://www.ibm.com/developerworks/cn/linux/l-ipc/part3/ 继续坚持,或许不能深刻理解,但至少要保证有印象. ~~~~~~~~~~~~~~ 消息队 ...
- Spring3 +mybatis3 之 MapperScannerConfigurer
之前一直使用"org.mybatis.spring.mapper.MapperFactoryBean"这个类在spring中配置mybatis的dao接口,后来发现如果dao太多话 ...
- 李洪强漫谈iOS开发[C语言-024]-表达式与赋值运算符