Educational Codeforces Round 48 (Rated for Div. 2)——A. Death Note ##
A. Death Note
2 seconds
256 megabytes
standard input
standard output
You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: "You have to write names in this notebook during nn consecutive days. During the ii-th day you have to write exactly aiai names.". You got scared (of course you got scared, who wouldn't get scared if he just receive a notebook which is named Death Notewith a some strange rule written in it?).
Of course, you decided to follow this rule. When you calmed down, you came up with a strategy how you will write names in the notebook. You have calculated that each page of the notebook can contain exactly mm names. You will start writing names from the first page. You will write names on the current page as long as the limit on the number of names on this page is not exceeded. When the current page is over, you turn the page. Note that you always turn the page when it ends, it doesn't matter if it is the last day or not. If after some day the current page still can hold at least one name, during the next day you will continue writing the names from the current page.
Now you are interested in the following question: how many times will you turn the page during each day? You are interested in the number of pages you will turn each day from 11 to nn.
The first line of the input contains two integers nn, mm (1≤n≤2⋅1051≤n≤2⋅105, 1≤m≤1091≤m≤109) — the number of days you will write names in the notebook and the number of names which can be written on each page of the notebook.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109), where aiai means the number of names you will write in the notebook during the ii-th day.
Print exactly nn integers t1,t2,…,tnt1,t2,…,tn, where titi is the number of times you will turn the page during the ii-th day.
3 5
3 7 9
0 2 1
4 20
10 9 19 2
0 0 1 1
1 100
99
0
In the first example pages of the Death Note will look like this [1,1,1,2,2],[2,2,2,2,2],[3,3,3,3,3],[3,3,3,3][1,1,1,2,2],[2,2,2,2,2],[3,3,3,3,3],[3,3,3,3]. Each number of the array describes during which day name on the
corresponding position will be written. It is easy to see that you should turn the first and the second page during the second day and the third page during the third day.
这个题特别简单,没有什么好说的,就是在这一天写最后写不到一整页的,分到第二天去写,因为翻页是按照写完这一页来看的
假设一页可以写4个名字,这一天打算写9个。
第一页写完,翻页第一次,还剩5个,
第二页写完,翻页第二次,还剩1个,
剩余的这一个可以写在第三页上,而为了方便计算,我们把剩余的这一页算在第二天上,于是计算第二天的时候又可以像第一天一样。
所以只要计算取余和取整就可以了。
#include<iostream>
using namespace std;
const int N=2e5+;
typedef long long ll;
ll a[N],ans[N];int n,m;
int main(){
ios::sync_with_stdio(false);cin.tie();
cin>>n>>m;
for(int i=;i<=n;i++)cin>>a[i];
for(int i=;i<=n;i++){
int x=a[i]%m;a[i+]+=x;
ans[i]=a[i]/m;
}
for(int i=;i<=n;i++)cout<<ans[i]<<" ";
}
Educational Codeforces Round 48 (Rated for Div. 2)——A. Death Note ##的更多相关文章
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
- Educational Codeforces Round 48 (Rated for Div. 2)
http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法 为什么我做了那么多讨论,原 ...
- Educational Codeforces Round 48 (Rated for Div. 2) B 1016B Segment Occurrences (前缀和)
B. Segment Occurrences time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Educational Codeforces Round 48 (Rated for Div. 2)异或思维
题:https://codeforces.com/contest/1016/problem/D 题意:有一个 n * m 的矩阵, 现在给你 n 个数, 第 i 个数 a[ i ] 代表 i 这一行所 ...
- Educational Codeforces Round 48 (Rated for Div. 2)G. Appropriate Team
题意:求满足条件的(i,j)对数:\(gcd(v,a_i)=x,lcm(v,a_j)=y\) 题解:\(x|a_i,a_j|y\),\(x|y\),考虑质因子p,假设a_i中p次数为a,x中次数为b, ...
- Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)
D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易 ...
- 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
[链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...
- [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)
[Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...
随机推荐
- 【Vue-Cli3.0】【2】渲染
哈哈哈,发工资啦,发工资啦,立刻就买了一个matebook D .开启了新的编程工作区了. 进入正题 Vue.js 的核心是一个允许采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统.这句话来自 ...
- 福州大学软件工程1916|W班 第6次作业成绩排名
作业链接 团队第三次-项目原型设计 评分细则 博客评分标准 在随笔开头,备注小组同学的学号.(1') 文字准确.样式清晰.图文并茂.字数在1000字左右.(10') 原型模型必须采用专用的原型模型设计 ...
- 2018-2019-2 网络对抗技术 20162329 Exp6 信息搜集与漏洞扫描
目录 Exp6 信息搜集与漏洞扫描 一.实践原理 1. 间接收集 2. 直接收集 3. 社会工程学 二.间接收集 1. Zoomeye 2. FOFA 3. GHDB 4. whois 5. dig ...
- VMware ESXi 6.5 安装
1.1下载esxi镜像 此处我使用的版本是:VMware-VMvisor-Installer-6.5.0-4564106.x86_64 1.2新建一个虚拟机,硬件兼容性处选择ESXI6.5 硬盘40g ...
- js计算发表的时间...分钟/小时以前/以后
网上找的都好复杂,这本来就是个粗略显示通俗的时间,绕来绕去都晕了 function timeAgo(o){ var n=new Date().getTime(); var f=n-o; var bs= ...
- DevExpress内 GridControl中复选框值问题
在DevExpress的 GridControl内的复选柜勾选后,界面看到是勾选状态,但对应的DataView的值仍未变,在以下事件内处理 在对应的DataView内的 CellValueChangi ...
- 记录opencv编译过程
准备学习opencv,参考了几个网页终于完成.编辑器和opencv版本都选择最新的版本. 记录过程如下 1. 下载准备: 1) Opencv源码, 下载地址: https://sour ...
- docker 设计原理
自从上次更新博客截至目前已经8个多月之久,在这大半年里面,我自己经历了好多,换了工作,换了定位,从之前的小运维,到现在负责整个运维部的工作,需要自己协调的事情更多了,最大的成长是可以通过自己的见解对公 ...
- LSI IBM服务器阵列卡操作经历
说明:因为服务器的一个磁盘坏了,因为没有经验不敢操作.正好有一台撤下来的相同服务器,所以查找了各种教程,研究了一下各种操作.记录在这里,防止忘记.一.概念说明raid(自己百度)阵列卡组(group) ...
- 矢量图形(vector graphics)和位图图像(bitmap)以及分辨率概念
第一篇:凭心而论.客观地认识矢量图形与位图图像http://www.dzwebs.net/2003.html 学习过物理的人都明白,矢量有大小和方向,而标量只有大小却没有方向: 但是在计算机里面,图形 ...