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 ...
随机推荐
- [10期]浅谈SSRF安全漏洞
引子:SSRF 服务端请求伪造攻击 很多web应用都提供从其他服务器上获取数据的功能.使用用户指定的URL,web应用可以从其他服务器获取图片,下载文件,读取文件内容等. 这个功能被恶意使用的话,可以 ...
- IDEA-包层级结构显示(三)
IntelliJ IDEA包层级结构显示 如:A.B.C,在项目中希望以如下形式显示: A B C 效果: 再更换为A.B.C形式显示
- StringBuffer 和Stringbuilder源码分析
首先看一下他们的继承关系 这个两个对象都继承了AbstractStringBuilder抽象类. 1.他们的实现方式都一样的,唯一区别的StringBuffer在多线程的时候是保证了数据安全, ...
- C++ 全面刨析使用指针方法 _new _delete
指针 #include<iostream> using namespace std; int main() { ; int* pn;//声明 int* pn = &avr;//初始 ...
- oracle--少见操作、如何调整dos窗口大小、字符集设置
如何调整dos窗口大小 1.set linesize 400; 2.右键 --默认值 断开.连接 disconn ; conn ww/ww; 关于字符集 操作系统环境变量针对语言项设置有几个,我经常设 ...
- 多线程10-SemaphoreSlim
); ;i<=;i++) { + * i; )); C ...
- Java初始化块及执行顺序
理解 初始化块又称为代码块.属于类中的第四大成员.本质上是一个方法,它也有方法体,但没有方法名,没有参数,没有返回,而且也不是通过对象或类名显式调用,而是通过隐式调用 是构造器的补充 语法 [修饰符] ...
- git的基本使用方法
git的基本使用方法:https://blog.csdn.net/qq_33316091/article/details/82414389
- [常用类]时间内Date、SimpleDateFormat、Calendar类
Date类的概述是util包下的,不能导入sql包的.* 类 Date 表示特定的瞬间,精确到毫秒. *构造方法 * public Date() * public Date(long date) 如果 ...
- 使用sql追踪
在会话层面使用sql追踪 1.查看sql追踪默认文件位置 2.设置trace文件名 alter session set tracefile_identifier='ymtrace001'; trace ...