Codeforces Round #275 (Div. 2) C
题目传送门:http://codeforces.com/contest/483/problem/C
题意分析:题目意思没啥好说的。
去搞排列列举必须TLE。那么就想到构造。 1。n。2。n-1。3。n-2这个样子。
k/2就是须要交换的元素对数,还须要考虑一下k的奇偶去推断没交换的元素是顺序输出还是逆序输出。自己尝试下几个数据就明确了。
代码:
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream> using namespace std; typedef long long LL; int p[100005];
int main()
{
int n,k;
while(cin>>n>>k)
{
for(int i=0; i<n; i++)
{
p[i]=i+1;
}
int flag=0;
int temp=n-1;
int m=k/2;
int x=k;
while(m--)
{
printf("%d ",p[flag]);
printf("%d ",p[temp]);
flag++;
temp--;
}
if(x%2==0)
{
for(int i=temp; i>=flag; i--)
{
printf("%d ",p[i]);
}
}
if(x%2==1)
{
for(int i=flag; i<=temp; i++)
{
printf("%d ",p[i]);
}
}
printf("\n");
}
}
Codeforces Round #275 (Div. 2) C的更多相关文章
- Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)
题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...
- Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造
Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 ht ...
- 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation
题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...
- [Codeforces Round #275 (Div. 2)]B - Friends and Presents
最近一直在做 codeforces ,总觉得已经刷不动 BZOJ 了? ——真是弱喵 你看连 Div.2 的 B 题都要谢谢题解,不是闲就是傻 显然我没那么闲 ╮(╯_╰)╭ 我觉得这题的想法挺妙的~ ...
- Codeforces Round #275(Div. 2)-C. Diverse Permutation
http://codeforces.com/contest/483/problem/C C. Diverse Permutation time limit per test 1 second memo ...
- Codeforces Round #275 (Div. 2)-A. Counterexample
http://codeforces.com/contest/483/problem/A A. Counterexample time limit per test 1 second memory li ...
- Codeforces Round #275 Div.1 B Interesting Array --线段树
题意: 构造一个序列,满足m个形如:[l,r,c] 的条件. [l,r,c]表示[l,r]中的元素按位与(&)的和为c. 解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的 ...
- Codeforces Round #275 (Div. 2)
A. Counterexample 题意:给出l,r,找出使得满足l<a<b<c<r,同时满足a,b的最大公约数为1,b,c的最大公约数为1,且a,b的最大公约数不为1 因为题 ...
- Codeforces Round #275 (Div. 2) 题解
A 题: 说的是在(LR) 之间找出ab互质 bc 互质 ac 不互质的 3个数 数据量小直接暴力 #include <iostream> #include <cstdio> ...
随机推荐
- 修改SVN路径
由于服务器IP更换,所以SVN的路径也就更换了. 更换SVN路径的做法是: 选中SVN checkout的文件夹,右键选择TortoiseSVN的relocate.注意要选择checkout的根目录, ...
- 华农oj Problem L: CreatorX背英语【STL】
Problem L: CreatorX背英语 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 53 Solved: 36 [Submit][Status][ ...
- WORDPRESS改为https部署
1.确保你已经正确开启了httpd 2.4.6的https配置,并且配置了该网站的虚拟主机,如下所示: <VirtualHost *:443> DocumentRoot "/ap ...
- (寒假集训)Roadblock(最短路)
Roadblock 时间限制: 1 Sec 内存限制: 64 MB提交: 9 解决: 5[提交][状态][讨论版] 题目描述 Every morning, FJ wakes up and walk ...
- EasyUI Datagrid 单元格编辑
3:对于单元格的编辑 $('#Units').datagrid({ pageNumber: 1, //url: "@ViewBag.Domain/Paper/GetQuestionUnit& ...
- SQL 增删改查 复习
首先创建两张表 CREATE TABLE Teacher ( Id ,) NOT NULL PRIMARY KEY, Name ) NOT NULL, ); CREATE TABLE Student ...
- 数据库系统入门 | Not Exisits 结构的灵活应用
教材 /<数据库系统概念>第六版第三章内容 机械工程出版社:实验软件/Qracle 11g 写在前面 用下面的样例1引出我们讨论的这一类方法. 样例1:使用大学模式,用SQL写出以下查询, ...
- ios禁用多按钮同时按下操作
[button setExclusiveTouch:YES]; 设置每个button的setExclusiveTouch:YES,可避免同时按下多个的问题
- java中终止线程的三种方式
在java中有三种方式可以终止线程.分别为: 1. 使用退出标志,使线程正常退出,也就是当run方法完成后线程终止. 2. 使用stop方法强行终止线程(这个方法不推荐使用,因为stop和sus ...
- “/”和“\\”和feof();
filename=c:/test/abc.text filename=c:\\test\\abc.test "\\"为转义字符: feof();函数检测文件是否已经到达末尾(EOF ...