Educational Codeforces Round 48 (Rated for Div. 2)A. Death Note(思维)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sugarbliss/article/details/81561118

题目链接:http://codeforces.com/problemset/problem/1016/A

题意:给你一个笔记本,笔记本上一页可以写m个名字,n代表n天,第二行n个数字代表每天写的名字个数(一页写不完就翻页),输出每一天翻页的次数。如果刚好写完一页翻页次数也要+1。

思路:把不够一页的名字用tmp记录,然后加上每一天要写的名字,答案就是tmp/m。

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int n, m, tmp, x;
int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        tmp += x;
        printf("%d ", tmp/m);
        tmp %= m;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/sugarbliss/article/details/81561118