题目大意

给你一个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. 20191103 《Spring5高级编程》笔记-第3章

    第3章 在Spring中引入IoC和DI 依赖注入是IOC的一种特殊形式,尽管这两个术语经常可以互换使用. 3.1 控制反转和依赖注入 IOC的核心是DI,旨在提供一种更简单的机制来设置组件依赖项,并 ...

  2. Hibernate的批量抓取

    批量抓取理解:如果我们需要查找到客户的所有联系人的话,按照正常的思路,一般是首先查询所有的客户,得到返回的客户的List集合.然后遍历List集合,得到集合中的每一个客户,在取出客户中的联系人(客户表 ...

  3. [19/05/08-星期三] JDBC(Java DataBase Connectivity)_ORM(Object Relationship Mapping, 对象关系映射)

    一.概念 基本思想: – 表结构跟类对应: 表中字段和类的属性对应:表中记录和对象对应: – 让javabean的属性名和类型尽量和数据库保持一致! – 一条记录对应一个对象.将这些查询到的对象放到容 ...

  4. 贪心(change)

    http://codeforces.com/gym/100989/problem/H After the data structures exam, students lined up in the ...

  5. SCUT - 77 - 哈利波特与他的魔法杖

    https://scut.online/p/77 METO说是单点更新线段树.要记录哪些点不用再更新,不太清楚具体是要怎么实现? 一个类似的想法是把n个点建一棵平衡树,每次节点变成0之后从树上移除,至 ...

  6. 回溯---IP 地址划分

    IP 地址划分 93. Restore IP Addresses(Medium) Given "25525511135", return ["255.255.11.135 ...

  7. git submodule删除多余模块

    rm -rf 子模块目录 删除子模块目录及源码 vi .gitmodules 删除项目目录下.gitmodules文件中子模块相关条目 vi .git/config 删除配置项中子模块相关条目 rm ...

  8. MVC项目集成swagger

    1.创建WebAPI项目解决方案 2.使用nuget引入Swashbuckle包 引入Swashbuckle包后App_Start文件夹下会多出一个SwaggerConfig文件 3.添加接口注释 项 ...

  9. linux--基础知识4

    #当前已什么用户登陆,创建的目录或文件,他的属组和主就是谁 #用户对目录拥有的几种权限 # ll -d查看目录当前权限信息 #r:可以查看该目录下的子文件名,子目录 #w:可以在该目录下创建,删除,重 ...

  10. 通过反射获取方法的参数名称(JDK8以上支持)

    方法的参数名,在很多时候我们是需要反射得到的.但是在java8之前,代码编译为class文件后,方法参数的类型是固定的,但参数名称却丢失了,这和动态语言严重依赖参数名称形成了鲜明对比.(java是静态 ...