题目大意

给你一个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. [Git] 005 初识 Git 与 GitHub 之分支

    在 GitHub 的 UI 界面使用 Git(多图警告) 1. 建立分支 1.1 点击左上方的 Branch: master,在输入框中填入分支名,再点击下方的 Create branch 1.2 此 ...

  2. JAVA总结--java基本语法

    static :静态的~ static :静态变量.静态方法: 被修饰的成员变量或者方法独立于该类的任何对象,只要该类被加载,被修饰的成员变量或者方法就存在并可以使用.  用public修饰的stat ...

  3. Spark-Core RDD的创建

    一.RDD创建的3种方式: 1.从集合中创建RDD 2.从外部存储创建RDD 3.从其他RDD转换得到新的RDD 二.从集合中创建RDD 1.使用parallelize函数创建 scala> v ...

  4. Java 和操作系统交互,你猜会发生什么?

    作者:lonelysnow https://www.jianshu.com/p/7f6832d61880 结合 CPU 理解一行 Java 代码是怎么执行的 根据冯·诺依曼思想,计算机采用二进制作为数 ...

  5. python 正确复制list,克隆list 的各种方案

    推荐4种方法 --------------------------------------------------------------- 方法一:extend L = [1, 2, 3] List ...

  6. 学Python的第四天

    第四天啦,今天依旧代码少的啃树皮.... 但是作业留的有了幼儿园的水准!!!让小编我看到了希望.... #!/usr/bin/env python # -*- coding:utf8 -*- impo ...

  7. 字符串format函数使用

    #format拼接字符串,format()内的参数必须为可迭代的对象p1="i am {2},age {1},{0}".format("seven",18,'a ...

  8. Object中有哪些公用方法?

    clone()方法 实现对象的浅复制,只有实现了Cloneable接口才能调用该方法. toString()方法 返回该对象的字符串表示. equals()方法: 在Object中与“==”的定义是一 ...

  9. Springboot aop使用

    package com.jxd.Boot.aspect; import org.aspectj.lang.JoinPoint;import org.aspectj.lang.Signature;imp ...

  10. mac os安裝jdk

    下載安裝 打开mac笔记本,输入账号密码登陆后,点击桌面上的terminal终端图标.打开终端,然后在终端中输入命令java.   从下面的图中可以看到,终端会自动给出提示,没有可以使用的java命令 ...