传送门: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. Redis核心原理-简单动态字符串SDS

    SDS简介 Redis是C语言编写的,但没有使用c语言的字符串结构,而是自己实现了一套简单动态字符串 simple dynamic string 简称SDS,SDS兼容C语言的字符串类型,原理类似Ja ...

  2. App控件定位

    本文将分享Android相关基础知识和Android APP控件定位工具的使用方法. Android基础知识 Android布局 Android是通过容器的布局属性来管理子控件的位置关系(iOS去掉了 ...

  3. 剑指Offer58-左转字符串

    题目 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果.对于一个给定的字符序列S,请你把其循环左移K位后的序列输出.例如,字符序列S=" ...

  4. 分别使用 Python 和 Math.Net 调用优化算法

    1. Rosenbrock 函数 在数学最优化中,Rosenbrock 函数是一个用来测试最优化算法性能的非凸函数,由Howard Harry Rosenbrock 在 1960 年提出 .也称为 R ...

  5. 物理STANDBY库创建还原点(打开为read write后再变回主库)

    开启STANDBY库为READ WRITE 1.取消主库传送归档 SQL> alter system set log_archive_dest_state_2=defer; 2.取消备库应用日志 ...

  6. [USACO2011 Feb] Cow Line

    原题链接https://www.lydsy.com/JudgeOnline/problem.php?id=3301 康拓展开和逆展开的模板题. #include<iostream> #in ...

  7. Django orm中related_name/related_query_name区别

    related_name/related_query_name区别 class Department(models.Model): title = models.CharField(verbose_n ...

  8. b站视频_下载_去水印_视频转mp4-批量下载神器

    b站下载_视频_去水印_转mp4_批量下载的解决办法 以下问题均可解决 b站下载的视频如何保存到本地 b站下载的视频在那个文件夹里 b站下载视频转mp4 b站下载app b站下载在哪 b站下载视频电脑 ...

  9. Vue基础之插值表达式的另一种用法!附加变量的监听!

    Vue基础之插值表达式的另一种用法!附加变量的监听! 讲这个之前我们先回顾一下原来的用法! <body> <!-- Vue.js的应用可以分为两个重要的组成部分 一个是视图! 另一个 ...

  10. (03)-Python3之--元组(tuple)操作

    1.定义 元组的关键字:tuple 元组以()括起来,数据之间用 , 隔开.元组当中的数据,可以是任意类型.数值是可以重复的. 元组元素是 不可变的,顺序是 有序的. 例如: b = ("萝 ...