题目大意

给你一个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. [9期]软WAF上传绕过+webshell免杀

    安全狗上传绕过 思路: 1.扰乱编码 form-data 替换成 ~form-data           form-data    改成 f+orm-data form-data    改成 for ...

  2. 腾讯视频的手机端的地址和PC端的地址是不一样的

    腾讯视频的手机端的地址和PC端的地址是不一样的,所以使用iframe的时候记得要使用手机端的地址

  3. python控制流-提前结束进程

    一.sys.exit() 调用 sys.exit()函数,可以让程序终止或退出. 这个函 数在 sys 模块中,必须先导入 sys,才能使用它: #!/usr/bin/env python #codi ...

  4. hackinglab 脚本关 writeup

    地址:http://hackinglab.cn 脚本关 key又又找不到了 点击提供的链接后,实际发生了两次跳转,key 在第一次跳转的网页中,key is : yougotit_script_now ...

  5. spring源码下载及转入ECLIPSE

    转自:https://www.cnblogs.com/scevecn/p/6043284.html 本例spring源码版本是4.3.0的, 所以jdk需要准备1.8的(不同版本源码要求的jdk不一样 ...

  6. CENTOS6.5 编译安装MySQL5.7.14

    前言 mysql5.7.14 编译安装在自定义文件路径下 下载安装包 配置安装环境 编译安装 cmake \ -DCMAKE_INSTALL_PREFIX=/data/db5714 \ -DMYSQL ...

  7. DelayQueue详解

    一.DelayQueue是什么 DelayQueue是一个无界的BlockingQueue,用于放置实现了Delayed接口的对象,其中的对象只能在其到期时才能从队列中取走.这种队列是有序的,即队头对 ...

  8. Vue组件定义

    简介 组件是可复用的 Vue 实例. 本质上是一个对象,该对象包含data.computed.watch.methods.filters以及生命周期钩子等成员属性. 组件结构: { data(){ r ...

  9. 浅析API和SDK

    前言 最近有小伙伴咨询胡哥关于API和SDK的概念以及区别,今天给大家来阐述下我的理解,手动微笑.gif. API 1. 定义 API(Application Programming Interfac ...

  10. SCRUM REPORT DIRECTORY

    Alpha sprint scrum 1 scrum 2 scrum 3 scrum 4 scrum 5 scrum 6 scrum 7 scrum 8 scrum 9 scrum 10 Beta s ...