题目大意

给你一个n

让你用1~2*n的数填满一个2*n个点的环

使得任意连续的n个位置的和的最大值减最小值不大于1

分析

我们通过瞎jb找规律发现n为偶数吴姐

而n为奇数我们设前n个位置为0组,后n个为1组

则这样填

1-0

2-1

3-1

4-0

5-0

6-1

7-1

8-0

不难看出规律

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int a[];
int main(){
int n,i,j,k;
scanf("%d",&n);
if(n&){
puts("YES");
for(i=;i<=n;i++)
if(i&)a[i]=*i-,a[n+i]=*i;
else a[i]=*i,a[n+i]=*i-;
for(i=;i<=*n;i++)printf("%d ",a[i]);
puts("");
}else puts("NO");
return ;
}

1206C Almost Equal的更多相关文章

  1. [LeetCode] Minimum Moves to Equal Array Elements II 最少移动次数使数组元素相等之二

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  2. [LeetCode] Minimum Moves to Equal Array Elements 最少移动次数使数组元素相等

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  3. [LeetCode] Partition Equal Subset Sum 相同子集和分割

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  4. Equal Sides Of An Array

    参考:http://stackoverflow.com/questions/34584416/nested-loops-with-arrays You are going to be given an ...

  5. Int,Long比较重使用equal替换==

    首先,==有很多限制,如Integer 类型的值在[-128,127] 期间,Integer 用 “==”是可以的(参考),超过范围则不行,那么使用equal则代替则完全ok public stati ...

  6. 无法解决 equal to 操作中 "SQL_Latin1_General_CP1_CI_AS" 和 "Chinese_PRC_CI_AS"

    无法解决 equal to 操作中 "SQL_Latin1_General_CP1_CI_AS" 和 "Chinese_PRC_CI_AS" 之间 2011-0 ...

  7. LeetCode Minimum Moves to Equal Array Elements II

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ 题目: Given a non-empt ...

  8. LeetCode Minimum Moves to Equal Array Elements

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/ 题目: Given a non-empty i ...

  9. conflict between "Chinese_PRC_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation

    在SQL SERVICE做关联查询的时候遇到了"conflict between "Chinese_PRC_CI_AI" and "Chinese_PRC_CI ...

随机推荐

  1. 应用安全-软件安全-漏洞CVE整理

    jira ssrf CVE-2019-8451 url = url + '/plugins/servlet/gadgets/makeRequest?url=' + host + '@www.baidu ...

  2. 2 python: Unicode 和list 列表

    1 unicode 2 list 列表及其内置函数等 3 不一样的for语句 Python 的 for 语句依据任意序列(链表或字符串)中的子项,按它们在序列中的顺序来进行迭代 >>> ...

  3. 错排问题 && 洛谷 P1595 信封问题

    传送门 一道裸的错排问题 错排问题 百度百科上这样说 就是对于一个排列,每一个数都不在正确的位置上的方案数.n 个元素的错排数记为 D(n). 公式 D(n)=(n−1)∗(D(n−2)+D(n−1) ...

  4. AcWing 802. 区间和

    (https://www.acwing.com/problem/content/804/) 假定有一个无限长的数轴,数轴上每个坐标上的数都是0. 现在,我们首先进行 n 次操作,每次操作将某一位置x上 ...

  5. [Java] 歐付寶金流串接教學

    前言: 很多接案的人,都會碰到需要接金流的時候.而歐付寶是個台灣的金流平台. 這邊記錄下,串接的心得.我用的語言是Java, 採liferay這個portal平台,不過這份教學當然適合servlet. ...

  6. 洛谷 - P3649 - 回文串 - 回文自动机

    https://www.luogu.org/problem/P3649 #include <bits/stdc++.h> using namespace std; typedef long ...

  7. 最全的 Java 知识总结- Github 日增 10 star

    项目地址: 如果觉得有帮助,希望大家给个 star 鼓励以下:同时也希望大家多多 fork,一起加入进来. 为什么选择做这个开源项目 首先,希望提高自己:因为选择做这个,自己肯定就会花时间去提高自己的 ...

  8. react依赖注入之mapStateToProps&&mapDispatchToProps

    今天看前辈写的代码,看到mapStateToProps&&mapDispatchToProps处,不明白,于是又是各种找资料,在CSDN博客中发现一篇好文,摘抄到此,方便自己阅读! 原 ...

  9. less:避免编译

    .box { width: ~"calc(300px - 30px)"; } 编译成css .box { width: calc(300px - 30px); } importan ...

  10. bzoj5518 & loj3046 「ZJOI2019」语言 线段树合并+树链的并

    题目传送门 https://loj.ac/problem/3046 题解 首先问题就是问有多少条路径是给定的几条路径中的一条的一个子段. 先考虑链的做法. 枚举右端点 \(i\),那么求出 \(j\) ...