题目

题目描述
You’ve got an array consisting of nn integers: a[1],a[2],…,a[n]a[1],a[2],…,a[n] . Moreover, there are mm queries, each query can be described by three integers l_{i},r_{i},k_{i}l
i

,r
i

,k
i

. Query l_{i},r_{i},k_{i}l
i

,r
i

,k
i

means that we should add to each element a[j]a[j] , where l_{i}<=j<=r_{i}l
i

<=j<=r
i

.

Record means the binomial coefficient, or the number of combinations from yy elements into groups of xx elements.

You need to fulfil consecutively all queries and then print the final array.

输入格式
The first line contains integers nn , mm ( 1<=n,m<=10^{5}1<=n,m<=10
5
).

The second line contains nn integers a[1],a[2],…,a[n]a[1],a[2],…,a[n] ( 0<=a_{i}<=10^{9}0<=a
i

<=10
9
) — the initial array.

Next mm lines contain queries in the format l_{i},r_{i},k_{i}l
i

,r
i

,k
i

— to all elements of the segment l_{i}…\ r_{i}l
i

… r
i

add number ( 1<=l_{i}<=r_{i}<=n1<=l
i

<=r
i

<=n ; 0<=k<=1000<=k<=100 ).

输出格式
Print nn integers: the ii -th number is the value of element a[i]a[i] after all the queries. As the values can be rather large, print them modulo 10000000071000000007 (10^{9}+7)(10
9
+7) .

题意翻译
给出nn个数,有mm个操作.

每个操作是将[L,R][L,R]之间的数加上C(j-L+k,k)C(j−L+k,k),L<=j<=RL<=j<=R.

最后输出这nn个数的值。

输入输出样例
输入 #1复制
5 1
0 0 0 0 0
1 5 0
输出 #1复制
1 1 1 1 1
输入 #2复制
10 2
1 2 3 4 5 0 0 0 0 0
1 6 1
6 10 2
输出 #2复制
2 4 6 8 10 7 3 6 10 15

思路

n阶差分
维护一下即可

代码


int n,m;
LL a[maxn];
LL c[maxn][maxm],ans[maxn][maxm]; void init() {c[0][0] = 1; for (int i = 1; i < maxn; ++i) {c[i][0] = 1; for (int j = 1; j <= i && j < maxm; ++j) {c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod; }}
}int main() {init(); scanf("%d%d",&n,&m); for (int i = 1; i <= n; ++i) scanf("%d",&a[i]);  int l,r,k; while (m--) { scanf("%d %d %d",&l,&r,&k); for (int i = 0; i <= k; ++i) ans[l][i] = (ans[l][i] + c[k][k-i]) % mod; for (int i = 0; i <= k; ++i)ans[r+1][i] = (ans[r+1][i] - c[r-l+k+1][k-i]) % mod; }for (int i = 1; i < n; ++i) {for (int j = 101; j >= 1; --j) {ans[i+1][j-1] = (ans[i+1][j-1] + ans[i][j] + ans[i][j-1]) % mod; }}for (int i = 1; i <= n; ++i) {printf("%lld ",((ans[i][0] + a[i]) % mod + mod) % mod); }return 0;
}

CF407C Curious Array相关推荐

  1. 老男孩上海校区Python面试题

    python面试题 第一章:python基础 数据类型: 1 字典: 1.1 现有字典 dict={'a':24,'g':52,'i':12,'k':33}请按字典中的 value 值进行排序? 1. ...

  2. php recordarray,Array 数组 - [ php中文手册 ] - 在线原生手册 - php中文网

    用户评论: [#1] florenxe [2015-10-07 18:53:45] //a nice little way to print leap years using array for ($ ...

  3. NumPy — 创建全零、全1、空、arange 数组,array 对象类型,astype 转换数据类型,数组和标量以及数组之间的运算,NumPy 数组共享内存

    NumPy 简介 一个用 python 实现的科学计算包.包括: 1.一个强大的 N 维数组对象 Array : 2.比较成熟的(广播)函数库: 3.用于整合 C/C++ 和 Fortran 代码的工 ...

  4. array.array python yhzf

    关于array: Python 本身没有数组这个说法, 有的就是list和tuple, list就具有其他语言中的数组特性. 至于list和tuple的区别,在于list可以在运行时修改内容和大小,t ...

  5. [JS]请给Array本地对象增加一个原型方法,它用于删除数组条目中重复的条目(可能有多个),返回值是一个包含被删除的重复条目的新数组。

    请给Array本地对象增加一个原型方法,它用于删除数组条目中重复的条目(可能有多个),返回值是一个包含被删除的重复条目的新数组. 刚开始复习js题还不太习惯 CSDN上看了一个帖子,说是牛客上的标答, ...

  6. hnswlib RuntimeError: Cannot return the results in a contigious 2D array. Probably ef or M is to sma

    1. 问题现象 index = hnswlib.Index(space = '100', dim = 512) index.init_index(max_elements = 100, ef_cons ...

  7. Array 数组去重 总结10方法(7)

    1,常规双循环去重(缺点:循环次数较多) Array.prototype.unique1 = function(){if(this === null){throw new TypeError('&qu ...

  8. ECMAScript——引用数据类型之array

    array 转载于:https://www.cnblogs.com/cataway/p/4967058.html

  9. leetcode:Search in Rotated Sorted Array

    题目要求: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 ...

  10. intval0.57100 php_php中0,'',null,false,true,FLASE,TREU,array()的相等恒等学习

    //比较值 '' NULL 0 false true FALSE TRUE //相等判断 //'' == NULL == 0 == false (相等) //array() = 0 == NULL = ...

最新文章

  1. Java改知能机_Java 面试突击之 Java 并发知识基础 进阶考点全解析
  2. fileinputstream resources 读取文件_压缩20M文件从30秒到1秒,包教包会
  3. oss图片尺寸调用方式_是时候来一场轰轰烈烈的OSS升级了
  4. 远程桌面服务器office版本,在启用远程桌面服务的计算机上部署 Office 2010
  5. 思博伦Landslide CORE帮助UQ实现自动化的现网测试
  6. java no provider for_No provider available for the service com.alibaba.
  7. 工作回忆总结(第二年)
  8. java自学路线图(超全超详细)
  9. 龙华大浪注塑加工中模具原理及组成
  10. 实变函数自制笔记1:前言
  11. python解析mht文件_实现MHT文件格式的解析和内容抽取
  12. crosses initialization of “XXX”
  13. elementUI环形进度条设置渐变色和修改底色
  14. GROMACS Tutorial 6-Free Energy Calculations
  15. java人才市场需求分析_人才招聘需求及分析报告.doc
  16. C++ POCO库(访问数据库,版本问题,本人配置失败)
  17. Meta-DETR: Image-Level Few-Shot Detection with Inter-Class Correlation Exploitation
  18. 《草书识别》隐私政策
  19. Mac OS X 系统更新升级包下载后的存储位置
  20. 很显然,现在元宇宙、web3.0的关注度,早已超过了区块链

热门文章

  1. marked转换html失败,解析markdown之marked
  2. 算法学习——图之有权图
  3. ps钢笔工具的详细讲解
  4. Linu基本知识(二)——Linux系统以及相关命令
  5. 查询mysql校对集语句_mysql 查询时指定校对规则
  6. Jupyter Notebook中使用conda配置的Python虚拟环境
  7. Ingress session sticky
  8. L1-009 N个数求和 (20 分)(C语言)(测试点3和测试点5)
  9. openstack下创建windows虚机出现do_hivex_close
  10. 分门别类刷leetcode——链表 1