A. Death Note

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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.

Examples
input

Copy
3 5
3 7 9
output

Copy
0 2 1 
input

Copy
4 20
10 9 19 2
output

Copy
0 0 1 1 
input

Copy
1 100
99
output

Copy
0 
Note

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 ##的更多相关文章

  1. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  2. Educational Codeforces Round 48 (Rated for Div. 2)

    http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法   为什么我做了那么多讨论,原 ...

  3. 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 ...

  4. Educational Codeforces Round 48 (Rated for Div. 2)异或思维

    题:https://codeforces.com/contest/1016/problem/D 题意:有一个 n * m 的矩阵, 现在给你 n 个数, 第 i 个数 a[ i ] 代表 i 这一行所 ...

  5. 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, ...

  6. 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 ...

  7. 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易 ...

  8. 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix

    [链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...

  9. [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)

    [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...

随机推荐

  1. 自我介绍&软工实践博客点评

    想想既然写了点评博客,那就顺便向同学们介绍下自己吧. 我是16届计科实验班的,水了两件小黄衫,于是就来当助教了_(:_」∠)_ 实话说身为同届生来当助教,我心里还是有点虚的,而且我还是计科的..感觉软 ...

  2. 简单使用WebSocket实现聊天室

    环境需求:flask,websocket第三方包 目录结构 web中实现群聊 ws_群聊.py文件 # 实现一个websocket 先下载包 gevent-websocket from flask i ...

  3. 2019-3-22c# TextBox只允许输入数字,禁用右键粘贴,允许Ctrl+v粘贴数字

    TextBox 禁止复制粘贴 ShortcutsEnabled =false TextBox只允许输入数字,最大长度为10 //TextBox.ShortcutsEnabled为false 禁止右键和 ...

  4. Spark环境搭建(五)-----------Spark生态圈概述与Hadoop对比

    Spark:快速的通用的分布式计算框架 概述和特点: 1) Speed,(开发和执行)速度快.基于内存的计算:DAG(有向无环图)的计算引擎:基于线程模型: 2)Easy of use,易用 . 多语 ...

  5. IDEA+Tomcat+Maven+SpringMVC基于Java注解配置web工程

    1.在IDEA中新建Maven工程,使用archetype. 2.添加Maven依赖 <dependencies> <dependency> <groupId>ju ...

  6. KindEditor富文本编辑器, 从客户端中检测到有潜在危险的 Request.Form 值

    在用富文本编辑器时经常会遇到的问题是asp.net报的”检测到有潜在危险的 Request.Form 值“一般的解法是在aspx页面   page  标签中加上 validaterequest='fa ...

  7. 矢量图形(vector graphics)和位图图像(bitmap)以及分辨率概念

    第一篇:凭心而论.客观地认识矢量图形与位图图像http://www.dzwebs.net/2003.html 学习过物理的人都明白,矢量有大小和方向,而标量只有大小却没有方向: 但是在计算机里面,图形 ...

  8. unittest各个组件之间的关系

    各个组件的含义: TestCase:测试用例,测试用例里面会有很多测试方法,是单元测试中最小维度的测试行为. TestSuite:测试套件,是测试用例的集合. TestFixure:测试固件,测试准备 ...

  9. Meltdown Attack

    1. 引言 2018年1月3日,Google Project Zero(GPZ)团队安全研究员Jann Horn在其团队博客中爆出CPU芯片的两组漏洞,分别是Meltdown与Spectre. Mel ...

  10. 关于条件语句和 a && b

    learn from javascript cookbook if (element == 'ab') array[index] = "**"; 该语句 等价于 if (eleme ...