传送门:D - Game With Array

题意:让你构造一个长度为n的序列,并且n个数的和为S,问能不能找到一个1~n的数k,使得数组里找不出一个子序列的和为k或者n-k;

题解:最简单的想法肯定是让k=1,然后数组只要不出现1和n-1就好了,只要 s /n >= 2,也就是由n-1个2和一个 s-(n-1)*2 != 1 构成就可以。

 1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4
5 int main()
6 {
7 ios::sync_with_stdio(false);
8 cin.tie(0);
9 cout.tie(0);
10 int n,m;
11 cin>>n>>m;
12 if(m/n>=2){
13 cout<<"YES"<<endl;
14 for(int i=0;i<n-1;i++) cout<<2<<' ';
15 cout<<m-(n-1)*2<<endl;
16 cout<<1<<endl;
17 }
18 else cout<<"NO"<<endl;
19 return 0;
20 }

Codeforces 1355 D. Game With Array的更多相关文章

  1. [codeforces 360]A. Levko and Array Recovery

    [codeforces 360]A. Levko and Array Recovery 试题描述 Levko loves array a1, a2, ... , an, consisting of i ...

  2. [Codeforces 266E]More Queries to Array...(线段树+二项式定理)

    [Codeforces 266E]More Queries to Array...(线段树+二项式定理) 题面 维护一个长度为\(n\)的序列\(a\),\(m\)个操作 区间赋值为\(x\) 查询\ ...

  3. Educational Codeforces Round 11 A. Co-prime Array 水题

    A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...

  4. Codeforces Round #504:D. Array Restoration

    D. Array Restoration 题目链接:https://codeforces.com/contest/1023/problem/D 题意: 给出一个序列,现在要求对一个全为0的序列执行q次 ...

  5. CodeForces 221D Little Elephant and Array

    Little Elephant and Array Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on C ...

  6. 【24.17%】【codeforces 721D】Maxim and Array

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 754A】Lesha and array splitting

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. [Educational Codeforces Round 63 ] D. Beautiful Array (思维+DP)

    Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds ...

  9. codeforces 442C C. Artem and Array(贪心)

    题目链接: C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

随机推荐

  1. Viser报错:dodge is not support linear attribute, please use category attribute!

    遇到这样的问题是因为x轴数据不能为为连续性的日期(日期格式为:YYYY-MM-DD),需要设置为分类属性(cat),有一些可能设置为timeCat,看具体情况 scale 参数支持以下类型 • ide ...

  2. Navcat连接Mysql报错1521

    原因是新版的MySql密码加密算法改变,导致旧版本的Navcat连接报错. 解决方案: 1.升级Navcat 因为只是本地的Mysql,所以没验证这个方法,网传可以,此处不介绍. 2.修改Mysql加 ...

  3. 【MyBatis】MyBatis 动态 SQL

    MyBatis 动态SQL if 可以根据实体类的不同取值,使用不同的 SQL 语句来进行查询. 使用动态 SQL 最常见情景是根据条件包含 where 子句的一部分. 持久层 DAO 接口: pub ...

  4. 【System】I/O密集型和CPU密集型工作负载之间有什么区别

    CPU密集型(CPU-bound) CPU密集型也叫计算密集型,指的是系统的硬盘.内存性能相对CPU要好很多,此时,系统运作大部分的状况是CPU Loading 100%,CPU要读/写I/O(硬盘/ ...

  5. 【RAC】双节点RAC搭建

    本文主要是双节点的RAC进行搭建,根据黄伟老师的视频进行总结和使用. 搭建环境: 1.两台安装好Linux_x64系统的服务器 2.IP设置 注意:Priv-IP的IP是自己一个网段,而剩下的SCAN ...

  6. 【Oracle】10g查看trace生成文件位置及文件名称

    select  u_dump.value || '/' ||  db_name.value || '_ora_' ||  v$process.spid ||  nvl2(v$process.trace ...

  7. 私有镜像仓库Harbor基础介绍与部署

    企业级私有镜像仓库Harbor 一:介绍 Harbor,是一个英文单词,意思是港湾,港湾是干什么的呢,就是停放货物的,而货物呢,是装在集装箱中的,说到集装箱,就不得不提到Docker容器,因为dock ...

  8. kubectl命令管理

    kubectl命令管理 查看更多帮助命令 [root@k8s-master ~]# kubectl --help 创建一个命名空间 [root@k8s-master ~]# kubectl creat ...

  9. 关于BAPI_GOODSMVT_CREATE中货物移动相关事务代码说明

    BAPI_GOODSMVT_CREATE参数 goodsmvt_code中的GM_CODE是为 BAPI 货物移动分配事务代码 其取值为下面对应的事务代码: 01 MB0102 MB3103 MB1A ...

  10. 阅读lodash源码之旅数组方法篇-compact和concat

    鲁迅说过:只有阅读过优秀库源码的人,才能配的上是真正的勇士. compact 创建一个新数组,包含原数组中所有的非假值元素.例如false, null,0, "", undefin ...