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. C++ 使用 hiredis 封装redis 的数据获取接口

    整合自互联网 一.hiredis 类库的安装 tar -zxvf hiredis-v0.13.3.tar.gz make make install mkdir /usr/lib/hiredis cp ...

  2. go片段代码

    关于枚举类型

  3. 渗透之Empire

    文中提及的部分技术可能带有一定攻击性,仅供安全学习和教学用途,禁止非法使用! Empire是一个纯碎的PowerShell后期漏洞利用代理工具,它建立在密码学.安全通信和灵活的架构之上.Empire实 ...

  4. SharePoint2016: 使用powerShell启用project web app

    1. 创建pwa承载的webApplication   在SharePoint2016管理中心>应用程序管理>管理web应用程序,新建web应用程序>sharepoint-1001, ...

  5. nodejs编译遇到的问题

    src\node_contextify.cc:631: Assertion 'args[1]->IsString()' failed. node 10 版本会出现这个问题, 安装natives后 ...

  6. 实验三:分别用for,while;do-while循坏语句以及递归的方法计算n!,并输出算式。

    源代码: package jiecheng;import java.util.Scanner;public class JieCheng {public static void main(String ...

  7. 实验5 Spark SQL编程初级实践

    今天做实验[Spark SQL 编程初级实践],虽然网上有答案,但都是用scala语言写的,于是我用java语言重写实现一下. 1 .Spark SQL 基本操作将下列 JSON 格式数据复制到 Li ...

  8. Python基础之面向对象3(继承)

    一.继承相关概念 1.语法: 2.定义: 3.优缺点: 4.相关概念: 5.相关内置函数: 6.继承内存图: 7.多继承: 二.多态相关概念 1.定义及作用: 2.重写概念: 3.运算符重载: 定义: ...

  9. Unity进阶----DoTween及工程文件夹的建立(2018/11/12)

    DoTween 仅介绍部分常用用法,代码参上:(其它操作见官网:http://dotween.demigiant.com/documentation.php) using System.Collect ...

  10. DCOS实践分享(3):基于Mesos 和 Docker 企业级移动应用实践分享

    2016年1月24日 8:00—19:00 北京万豪酒店(东城区建国门南大街7号) @Container大会是由国内容器社区DockOne组织的专为一线开发者和运维工程师设计的顶级容器技术会议,会议强 ...