CF1157D N Problems During K Days
思路:
在1, 2, 3, ... , k的基础上贪心构造。
实现:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[];
int main()
{
int n, k;
while (cin >> n >> k)
{
if (n < (ll)k * (k + ) / ) { cout << "NO" << endl; continue; }
if (k == ) { cout << "YES\n" << n << endl; continue; }
if (k == && n == ) { cout << "NO" << endl; continue; }
for (int i = ; i <= k; i++) a[i] = i;
ll r = n - k * (k + ) / ;
int d = r / k, t = r % k;
for (int i = ; i <= k; i++) a[i] += d;
while (t && a[k] < a[k - ] * ) { a[k]++; t--; }
int i = k - ;
for ( ; i > k - - t; i--) a[i]++;
if (a[i + ] > a[i] * ) cout << "NO" << endl;
else
{
cout << "YES" << endl;
for (int i = ; i <= k; i++) cout << a[i] << " ";
cout << endl;
}
}
return ;
}
CF1157D N Problems During K Days的更多相关文章
- CF1157D N Problems During K Days(简单构造)
题目 题目 原数据是水成啥样了,\(<\longrightarrow <=,>=\longrightarrow <=,\)这也能过 被\(hack\)后身败名裂 做法 简单的贪 ...
- Codeforces Round #555 (Div. 3) D. N Problems During K Days 【数学思维】
一 题面 D. N Problems During K Days 二 分析 对于这题,刚开始我就是陷入了对公式的执着,企图用公式直接确定第一个数,然后试着去找序列.经过思考和手动模拟后发现是很难保证正 ...
- Codeforce Round #555 Div.3 D - N Problems During K Days
构造题 话说挺水的题..当时怎么就WA到自闭呢.. 先把每个位置按照最低要求填满,也就是相差1..然后从最后一位开始把剩下的数加上,直到不能加为止. #include <bits/stdc++. ...
- Codeforces Round #555 (Div. 3)[1157]题解
不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...
- 软件工程课程作业(三)--四则运算3(C++)
伙伴链接:http://www.cnblogs.com/haoying1994/ 一.设计思路 在此前程序拥有的功能:加减有无负数,除法有无余数以及算式可定制的功能的基础上,此次程序又添加了算式结果的 ...
- 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...
- Codeforces Round #555 (Div. 3) c2 d e f
c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...
- Codeforces Round #127 (Div. 1) D. Brand New Problem 暴力dp
D. Brand New Problem 题目连接: http://www.codeforces.com/contest/201/problem/D Description A widely know ...
- CF 1006B Polycarp's Practice【贪心】
Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a ...
随机推荐
- 51 nod 1522 上下序列——序列dp
题目:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1522 很好的思想.考虑从小到大一对一对填数,这样也能对它的大小限制 ...
- 洛谷P1220关路灯——区间DP
题目:https://www.luogu.org/problemnew/show/P1220 区间DP. 代码如下: #include<iostream> #include<cstd ...
- TreeView滚动TreeViewItem
今天帮忙修了一个bug, 在拖动TreeViewItem时,需要滚动TreeView向前翻页,或向后翻页. 思路: 1.找到TreeView控件里的ItemsControl 2.找到ItemsCont ...
- struts2的使用知识点
最开始学习java的时候学习过struts,但是对配置和struts的理解深度不够,现在工作虽然再用,但是自己搭建环境和使用心得始终很零散,所以现在决定重新理一遍,有条理的学习一下struts. 至于 ...
- windows平台下新网络库RIO ( Winsock high-speed networking Registered I/O)
What's New for Windows Sockets Microsoft Windows 8 and Windows Server 2012 introduce new Windows Soc ...
- matlab形态学图像处理之strel函数
转自:http://blog.sina.com.cn/s/blog_b1cd5d330101pmwi.html strel--structuring element 运用各种形状和大小构造元素,基本语 ...
- React-Redux之API
connect([mapStateToProps], [mapDispatchToProps], [mergeProps],[options]) 连接 React 组件与 Redux store. 连 ...
- 【hdu2955】 Robberies 01背包
标签:01背包 hdu2955 http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意:盗贼抢银行,给出n个银行,每个银行有一定的资金和抢劫后被抓的概率,在 ...
- 23.Consent 代码重构
新建Services文件,并新建类ConsentService类把,ConsetController里面不是Action的方法都放在这个ConsentService类里面 先把构造函数完善 把这些私有 ...
- VMware S/4 HANA OP 1511虚拟机下载,64G内存限制解决方案
http://www.itpub.net/thread-2057212-1-1.html S4 HANA OP 1511 Scale Out