1206C Almost Equal
题目大意
给你一个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的更多相关文章
- [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 ...
- [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 ...
- [LeetCode] Partition Equal Subset Sum 相同子集和分割
Given a non-empty array containing only positive integers, find if the array can be partitioned into ...
- Equal Sides Of An Array
参考:http://stackoverflow.com/questions/34584416/nested-loops-with-arrays You are going to be given an ...
- Int,Long比较重使用equal替换==
首先,==有很多限制,如Integer 类型的值在[-128,127] 期间,Integer 用 “==”是可以的(参考),超过范围则不行,那么使用equal则代替则完全ok public stati ...
- 无法解决 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 ...
- LeetCode Minimum Moves to Equal Array Elements II
原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ 题目: Given a non-empt ...
- LeetCode Minimum Moves to Equal Array Elements
原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/ 题目: Given a non-empty i ...
- 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 ...
随机推荐
- 浅谈vue单页面seo问题
最近做项目的时候,被要求做seo,由于项目已经开发完毕,且只需首页做seo,所以考虑再三,决定用prerender-spa-plugin结合vue-meta-info来实现首页的seo.如果你的页面是 ...
- .aspx和.aspx.cs之间的区别
在vs里面创建一个web窗体会产生两种文件:后缀是.aspx和.aspx.cs. 简单的来说,.aspx是表现层,可以简单理解为是写html代码的,界面的设计部分:.cs是对应的逻辑代码,再通过特定的 ...
- 两台电脑使用ROS通讯
一.ROS分布式多机通讯简介 ROS是一种分布式软件框架,节点之间通过松耦合的方式组合,在很多应用场景下,节点可以运行在不同的计算平台上,通过Topic,Service通信. 但是各个节点只能共同拥有 ...
- javascript自定义Map对象
javascript定义map对象开发前端组件的重要性就不过多阐述了,直接参考以下案例即可 <script type=text/javascript charset=utf-8> func ...
- .net core 自定义中间件
public class MyMiddleware { //private IConfiguration _configuration; //第一步: private RequestDelegate ...
- vue 运行时报 dependency was not found:错误
这种报错我知道的有两种情况引起: 第一种: 是在引入文件的时候路径不对, 解决办法是: 只要在加一个./就行了: import test from './test' 改成先对路径 如果是安装的模块的话 ...
- 小白学Python(12)——pyecharts ,生成词云图 WordCloud
WordCloud(词云图) from pyecharts import options as opts from pyecharts.charts import Page, WordCloud fr ...
- PS使用记录:人像(证件照)更换背景
PS使用记录:人像(证件照)更换背景 参考:非常干净的抠羽毛ps教程抠图羽毛 (1)准备2019PS,原图 (2)选择人像:选择->主体 (3)边缘处理:选择 ->选择并遮住 ->选 ...
- C#开发 WinForm如何在选项卡中集成加载多个窗体 实现窗体复用
http://blog.csdn.net/upi2u/article/details/37914909 最近需要做的一个项目,为了避免从菜单中选择的麻烦,需要把几个窗体集成到一起,通过TabContr ...
- BUUCTF--findit
测试文件:https://buuoj.cn/files/7b8602971727c6c82ec0d360d5cad2c0/6a428ff2-25d7-403c-b28e-3f980a10a5a2.ap ...