CF 482A(Diverse Permutation-相邻距离不同数为k的1~n全排列构造)
来源:互联网 发布:c语言汉化版 编辑:程序博客网 时间:2024/06/14 07:30
1 10 2 9 3 8 |7 6 5 4 3 2
不同的。。。全为1的
#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<functional>#include<iostream>#include<cmath>#include<cctype>#include<ctime>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=pre[x];p;p=next[p])#define Forpiter(x) for(int &p=iter[x];p;p=next[p]) #define Lson (x<<1)#define Rson ((x<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (100000007)#define MAXN (100000+10)#define MAXK (100000+10)long long mul(long long a,long long b){return (a*b)%F;}long long add(long long a,long long b){return (a+b)%F;}long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}typedef long long ll;int n,k;int main(){//freopen("CF482A.in","r",stdin);//freopen(".out","w",stdout);cin>>n>>k;k--;int l=1,r=n,b=1;while(l<=r){if (b) printf("%d",l++);else printf("%d",r--);if (k) b^=1,k--; if (l<=r) putchar(' ');}cout<<endl;return 0;}
0 0
- CF 482A(Diverse Permutation-相邻距离不同数为k的1~n全排列构造)
- Codeforces 482A Diverse Permutation(构造)
- 482 A. Diverse Permutation
- 构造法——Diverse Permutation ( CodeForces 482A )
- CodeForces 482A Diverse Permutation
- CodeForces 482A Diverse Permutation
- coderforce 482A. Diverse Permutation
- 考题一:研究对全排列着色的性质 问题 A: 首先需要生成 n 的全排列然后对 n 的全排列进行着色, 使得相邻的两个数只需用最少颜色就可以把相邻的两个数用那区分开. (这里相邻包含两层含义:同时在自然
- 【构造】【cf482A】Diverse Permutation
- LeetCode-------60. Permutation Sequence(n的全排列中第K列)
- leetcode_60. Permutation Sequence 找n的全排列中的第k个序列
- 对集合{1, 2, 3, …, n}中的数进行全排列,可以得到 n!个不同的排列方式
- codeforces 482A Diverse Permutation 贪心
- Diverse Permutation - CodeForces 482 A 水题
- A. Diverse Permutation
- 输入一个数n,输出1~n的全排列
- Permutation Sequence 全排列的第k个数 python
- 数据结构与算法[LeetCode]—Permutation Sequence 求n个数的全排列中第K个序列
- Objective-C对象模型及应用
- cocos: command not found
- 添加css样式的三种方法
- 在Excel图表中同时显示两组刻度单位不同的数据
- C++中动态定义一维数组,二维数组,三维数组的方法
- CF 482A(Diverse Permutation-相邻距离不同数为k的1~n全排列构造)
- 5.多线程学习--等待线程的终结
- 基于MFC的ActiveX控件开发
- dba_free_space中同一个file_id存在多条记录的问题
- IE9面向开发人员的ActiveX筛选
- Java 初探关于Data Structure
- Android版:验证手机号码的正则表达式
- JSON 数据解析笔记
- <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 的说明