题意:无限页的书,每页可以写m个名字,给你一个长度为n的序列,序列为你每天要写的名字数,输出你每天要翻的页数。

n<=2e5,m,a[i]<=1e9

思路:

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<string>
  4. #include<cmath>
  5. #include<iostream>
  6. #include<algorithm>
  7. #include<map>
  8. #include<set>
  9. #include<queue>
  10. #include<vector>
  11. using namespace std;
  12. typedef long long ll;
  13. typedef unsigned int uint;
  14. typedef unsigned long long ull;
  15. typedef pair<int,int> PII;
  16. typedef vector<int> VI;
  17. #define fi first
  18. #define se second
  19. #define MP make_pair
  20. #define MOD 1000000007
  21. #define N 210000
  22.  
  23. ll a[N],b[N];
  24. ll n,m;
  25.  
  26. int read()
  27. {
  28. int v=,f=;
  29. char c=getchar();
  30. while(c<||<c) {if(c=='-') f=-; c=getchar();}
  31. while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
  32. return v*f;
  33. }
  34.  
  35. int main()
  36. {
  37. //freopen("1.in","r",stdin);
  38. //freopen("1.out","w",stdout);
  39. scanf("%d%d",&n,&m);
  40. for(int i=;i<=n;i++) scanf("%lld",&a[i]);
  41. ll now=,sum=;
  42. ll ans=;
  43. for(int i=;i<=n;i++)
  44. {
  45. if(now+a[i]<m) {now+=a[i];b[i]=ans;}
  46. else
  47. {
  48. a[i]-=(m-now);
  49. ans++;
  50. ans+=(a[i]/m);
  51. now=a[i]%m;
  52. b[i]=ans;
  53. }
  54. }
  55. for(int i=;i<=n;i++) printf("%lld ",b[i]-b[i-]);
  56. return ;
  57. }

【CF1016A】Death Note(签到)的更多相关文章

  1. Educational Codeforces Round 48 (Rated for Div. 2)——A. Death Note ##

    A. Death Note time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  2. Death Note

    注:本文系作者原创,但可随意转载. ********************************************************************************** ...

  3. Educational Codeforces Round 48

    题目地址 Edu48 A.Death Note 翻译 你有一个无穷页的本子,每一页可以写\(m\)个名字, 你在第\(i\)天要写\(a_i\)个名字,如果这一页恰好写满了,你就会翻页, 问每天的翻页 ...

  4. 用Python做词云可视化带你分析海贼王、火影和死神三大经典动漫

    对于动漫爱好者来说,海贼王.火影.死神三大动漫神作你肯定肯定不陌生了.小编身边很多的同事仍然深爱着这些经典神作,可见"中毒"至深.今天小编利用Python大法带大家分析一下这些神作 ...

  5. Codeforces Edu Round 48 A-D

    A. Death Note 简单模拟,可用\(\%\)和 \(/\)来减少代码量 #include <iostream> #include <cstdio> using nam ...

  6. 字符串(AC自动机):HDU 5129 Yong Zheng's Death

    Yong Zheng's Death Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/O ...

  7. WeMall微信商城签到插件Sign的主要源码

    WeMall微信商城源码签到插件Sign,用于商城的签到系统,分享了部分比较重要的代码,供技术员学习参考 AdminController.class.php <?php namespace Ad ...

  8. C#开发微信门户及应用(39)--使用微信JSSDK实现签到的功能

    随着微信开逐步开放更多JSSDK的接口,我们可以利用自定义网页的方式来调用更多微信的接口,实现我们更加丰富的界面功能和效果,例如我们可以在页面中调用各种手机的硬件来获取信息,如摄像头拍照,GPS信息. ...

  9. 三星Note 7停产,原来是吃了流程的亏

    三星Note 7发售两个月即成为全球噩梦,从首炸到传言停产仅仅47天.所谓"屋漏偏逢连天雨",相比华为.小米等品牌对其全球市场的挤压.侵蚀,Galaxy Note 7爆炸事件这场连 ...

随机推荐

  1. SVN:The working copy is locked due to a previous error (二)

    之前也碰到过这种问题,但是根本问题不同,解决方案不同. 传送门:SVN:The working copy is locked due to a previous error (二) 本次错误如图: 解 ...

  2. jq 下拉框

    <div class="alls"> <div class="item"> <div class="all"& ...

  3. Java中的==和equals的区别详解

    1.基础知识 (1)String x = "hello"; (2)String x = new String ("hello"); 第1种方式的工作机制是,首先 ...

  4. python入门:if和else的基本用法

    #!/usr/bin/env python # -*- coding:utf-8 -*- #2.X用raw_input,3.X用input #if和else的基本用法 name = input(&qu ...

  5. 【python学习】新手基础程序练习(一)

    首先得先编一下程序员必须编的程序——Hello World……(这应该是程序员情结...) #coding=utf-8 #Version:python3.7.0 #Tools:Pycharm 2017 ...

  6. UVa - 1593 代码对齐(STL)

    看上去十分麻烦的一道题,但是看了看别人的写法感觉大神们写的无比简单. 就是记一个每列单词的最大长度,然后剩下的事交给NB的iomanip头文件就好. stringsteam是一个神奇的东西. #inc ...

  7. re--findall 【转】

    原文链接 python re 模块 findall 函数用法简述 代码示例: >>> import re >>> s = "adfad asdfasdf ...

  8. POJ 2763 树链剖分 线段树 Housewife Wind

    单个边的权值修改以及询问路径上的权值之和. 数据量比较大,用vector存图会超时的. #include <iostream> #include <cstdio> #inclu ...

  9. 使用Jquery与vuejs操作dom比较

    jquery实现添加功能 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  10. python - 接口自动化测试 - ReadExcel - 读取测试数据封装

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: read_excel.py @ide: PyCharm C ...