cf B. Permutation
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int a[];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=; i<=*n; i++)
{
a[i]=i;
}
for(int i=; i<=k; i++)
{
swap(a[*i-],a[*i]);
}
for(int i=; i<=*n; i++)
{
if(i==) printf("%d",a[i]);
else printf(" %d",a[i]);
}
printf("\n");
return ;
}
http://codeforces.com/contest/359/problem/B
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n,k; int main()
{
while(scanf("%d%d",&n,&k)!=EOF)
{
printf("%d",k+);
for(int i=; i<=*n; i++)
{
if(i!=k+) printf(" %d",i);
}
printf("\n");
}
return ;
}
cf B. Permutation的更多相关文章
- CF数据结构练习
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...
- Good Triple CodeForces - 1169D (等差子序列)
大意: 给定01字符串, 求有多少个区间$[l,r]$, 使得存在正整数$x,k$满足$1\le x,k\le n,l\le x<x+2k\le r,s_x=s_{x+k}=s_{x+2k}$. ...
- 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 ...
- CF&&CC百套计划3 Codeforces Round #204 (Div. 1) E. Jeff and Permutation
http://codeforces.com/contest/351/problem/E 题意: 给出一些数,可以改变任意数的正负,使序列的逆序对数量最少 因为可以任意加负号,所以可以先把所有数看作正数 ...
- CF 1033 C. Permutation Game
C. Permutation Game http://codeforces.com/contest/1033/problem/C 题意: 一个排列,每个位置i走到的位置j满足:a[j]>a[i] ...
- [CF 612E]Square Root of Permutation
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, ...
- CF 1141C Polycarp Restores Permutation
Description An array of integers p1,p2,…,pnp1,p2,…,pn is called a permutation if it contains each nu ...
- CF R 209 div 2 CF359B Permutation 构造
LINK:Permutation 休闲一下 开了一道构造题. 看起来毫无头绪 其实仔细观察第二个条件 0<=2k<=n. 容易想到当n是奇数的时候 k的范围更小 再手玩一下第一个条件 容易 ...
- cf B. Levko and Permutation
http://codeforces.com/contest/361/problem/B #include <cstdio> #include <cstring> #includ ...
随机推荐
- MFC中DoDataExchange()的作用
void CDlgSelectCS::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Te ...
- 【HDOJ】1315 Basic
这道题目巨坑啊,注意__int64,int wa了一个下午. #include <cstdio> #include <cstring> #include <cstdlib ...
- css实现居中的各种方法
css垂直居中有很多种方法,可以参考下这个网站
- zabbix流量汇聚
"服务器流量汇总"领导提需求,要把几个数据中心的数据汇总起来,于是就google了一下"zabbix流量汇总" 按照其中一篇博客做了出来,博客地址如下. htt ...
- 关于javax.crypto.BadPaddingException: Blocktype错误的几种解决方法
此文章转载自:http://www.myexception.cn/mobile/1259076.html 关于javax.crypto.BadPaddingException: Blocktype异常 ...
- C++ lambda 表达式传递的变量默认不可变
我遇到例如以下问题: int count=0; listener->onTouchMoved=[count](Touch* t,Event* e){ count++; log("onT ...
- 【Spring MVC系列】--(5)理解AOP
1.java反射 实用:JAVA反射机制及应用例子 http://407827531.iteye.com/blog/1173930 系统:java反射原理 http://china-jianchen. ...
- solr 3.5 配置及server设置
一.solr 的简单介绍 Apache Solr 是一个开源的搜索server.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache Solr 中 ...
- Ignatius and the Princess III --undo
Ignatius and the Princess III Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (J ...
- linux下查阅文件内容cat,more,less,tail
1.常用cat,直接查看,一次性全部输出 cat filename cat -b filename 显示行号,除空白行 cat -n 显示行号,包括空白行 常用:cat filename | ...