Codeforce Round #555 Div.3 D - N Problems During K Days
构造题
话说挺水的题。。当时怎么就WA到自闭呢。。
先把每个位置按照最低要求填满,也就是相差1。。然后从最后一位开始把剩下的数加上,直到不能加为止。
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define full(a, b) memset(a, b, sizeof a)
using namespace std;
typedef long long ll;
inline int lowbit(int x){ return x & (-x); }
inline int read(){
int X = 0, w = 0; char ch = 0;
while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
while(isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
return w ? -X : X;
}
inline int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b; }
inline int lcm(int a, int b){ return a / gcd(a, b) * b; }
template<typename T>
inline T max(T x, T y, T z){ return max(max(x, y), z); }
template<typename T>
inline T min(T x, T y, T z){ return min(min(x, y), z); }
template<typename A, typename B, typename C>
inline A fpow(A x, B p, C lyd){
A ans = 1;
for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd;
return ans;
}
ll a[100005];
int main(){
ll n, k, sum = 0;
cin >> n >> k;
for(int i = 1; i <= k; i ++){
a[i] = i, sum += i;
}
if(sum > n){
printf("NO\n");
}
else{
ll tmp = (n - sum) / k;
if(tmp > 0){
for(int i = 1; i <= k; i ++) a[i] += tmp, sum += tmp;
}
for(int i = k; i >= 1; i --){
int cnt = 0;
while(a[i] < 2 * a[i - 1] && sum < n) a[i] ++, sum ++, cnt ++;
if(!cnt && sum < n){
printf("NO\n");
break;
}
if(sum == n){
printf("YES\n");
for(int j = 1; j <= k; j ++){
cout << a[j];
if(j != k) cout << " ";
}
break;
}
}
}
return 0;
}
Codeforce Round #555 Div.3 D - N Problems During K Days的更多相关文章
- Codeforces Round #555 (Div. 3) D. N Problems During K Days 【数学思维】
一 题面 D. N Problems During K Days 二 分析 对于这题,刚开始我就是陷入了对公式的执着,企图用公式直接确定第一个数,然后试着去找序列.经过思考和手动模拟后发现是很难保证正 ...
- 老年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)[1157]题解
不得不说这场div3是真的出的好,算得上是从我开始打开始最有趣的一场div3.因为自己的号全都蓝了,然后就把不经常打比赛的dreagonm的号借来打这场,然后...比赛结束rank11(帮dreago ...
- Codeforces Round #555 (Div. 3) c2 d e f
c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...
- Codeforces Round #555 (Div. 3) 解题报告
A.Reachable Numbers 题意: 给定操作f(x):将x加1,删去得到的数的所有末尾0,如f(10099)=10099+1=10100→1010→101.现在给定一个数n,对n进行无限次 ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B. Problems for Round 水题
B. Problems for Round 题目连接: http://www.codeforces.com/contest/673/problem/B Description There are n ...
- codeforce round #467(div.2)
A. Olympiad 给出n个数,让你找出有几个非零并且不重复的数 所以用stl的set //#define debug #include<stdio.h> #include<ma ...
- codeforce round#466(div.2)C. Phone Numbers
C. Phone Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...
- codeforce round#466(div.2) B. Our Tanya is Crying Out Loud
B. Our Tanya is Crying Out Loud time limit per test1 second memory limit per test256 megabytes input ...
随机推荐
- 18-09-20,String 与 StringBuilder (StringBuffer)
1.其一 在运行速度方面:StringBuilder > StringBuffer > String 上实例 class Program { static void Main(string ...
- PhotoshopCS5中将单位修改成百分比
PhotoshopCS5中单位默认是厘米或px,当用同一动作修改两张照片时,会因为片子大小不同,修改收到影响.若将单位修改成百分比,则动作会根据照片大小,自动进行调整. 1)选择菜单栏中的“编辑”选项 ...
- axios+Vue上传文件显示进度
一,前言 最近在用Vue,然后上传文件时需要显示进度,于是网上搜了一下,经过自己实测终于也弄明白了 二,效果 三,代码 HTML代码 <div id="app"> &l ...
- MySQL分组查询与连接查询
一,分组查询 使用ORDER BY子句将表中的数据分成若干组(还是按行显示) 语法: SELECT 字段名[,聚集函数] FROM 表名 [WHERE子句] GROUP BY 要分组的字段名 [ORD ...
- wordpress 角色权限
自带多媒体库上传权限:edit_other_pages
- Windows有点腻了?不如试试Ubuntu.
最近在接触Python. 因为担心环境会向Java一样,很容易影响当前的工作电脑. 所以准备搭建一台虚拟机,不过Windows的尺寸是在太大了.所以,选择安装Ubuntu. Ubuntu官方网站地址: ...
- DVWA 黑客攻防演练(十一) 存储型 XSS 攻击 Stored Cross Site Scripting
上一篇文章会介绍了反射型 XSS 攻击.本文主要是通过 dvwa 介绍存储型 XSS 攻击.存储型 XSS 攻击影响范围极大.比如是微博.贴吧之类的,若有注入漏洞,再假如攻击者能用上一篇文章类似的代码 ...
- js判断浏览器是否支持webGL
起因是我之前开发的网页,用到了three.js制作了一个3d的旋转球体效果. 在各种浏览器上运行都没问题,在IE上也做了兼容代码. 但是今天接电话,老板说你这网页在xp上不显示啊.IE上好使.goog ...
- ios定义数组和字典快捷方式
//标准写法 NSNumber * number = [NSNumber numberWithInt:1]; NSArray * array = [NSArray arrayWithObjects:@ ...
- html元素禁用disable or enable
场景说明 ajax提交数据,防止收到服务端相应前用户重复点击. 1.用户点击按钮,禁用当前按钮,发起ajax请求. 2.收到ajax请求,还原当前按钮. html解决方案 参考地址:http://ww ...