当前位置:网站首页>Prefix sum and difference
Prefix sum and difference
2022-06-21 08:51:00 【Stephen_ Curry___】
The prefix and
One dimensional prefix and preprocessing :
sum[i]=sum[i-1]+a[i];
Two dimensional prefix and preprocessing template :
sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j];
Difference
One dimensional difference
// to l~r Add all the numbers of the interval x
d[l]+=x;
d[r+1]-=x;
Two dimensional difference
// Give (x1,y1) It's the upper left corner ,(x2,y2) Add all the numbers in the lower right corner x
d[x1][y1]+=x;
d[x2+1][y1=-=x;
d[x1][y2+1]-=x;
d[x2+1][y2+1]+=x;
边栏推荐
- Joking Domain Driven Design (VI) -- Boundary context -- Design
- PS prompts "script error -50 general Photoshop error, how to solve it?
- Unmanned, automation technology affects the world
- Storage of C language integer in memory
- Idea common code templates
- finally block can not complete normally
- 声临其境 — 音频沉浸体验
- tidb4.0.0遇见的问题、报错总结(tiup部署)
- adb使用技巧和usb通信原理
- Unity 5 自带的Mono也可以支持C# 6
猜你喜欢

Visual studio code annotation plug-in: korofileheader

优化食品生产行业库存管理的6种方法

Unity 5 自带的Mono也可以支持C# 6

【活动早知道】LiveVideoStack近期活动一览

FD:文件描述符

Using the method of combining shapes in illustrator

TiDB3.0- 4.0 内存控制/修改日志保存天数/最大索引长度

Ads Filter Design Wizard tool 2

《网络是怎么样连接的》读书笔记 - FTTH

What should I do if a white page appears during MySQL installation
随机推荐
Two image enhancement methods: image point operation and image graying
Gql+nodejs+mysql database
leetcode:19. Delete the penultimate node of the linked list
Unity .net 框架问题
The skill of using ADB and the principle of USB communication
Can you implement these requirements with MySQL
【活动早知道】LiveVideoStack近期活动一览
WordPress media library supports uploading and previewing SVG icons
Wechat applet
给定一个m*n的二维列表,查找一个数是否存在
Reading method (three times reading method)
Leedcode 1 - sum of two numbers
Decrypt FTP
Understanding and use of advanced pointer
Unity 5 自带的Mono也可以支持C# 6
Talking about Festinger effect
Doc common syntax, updating
PS prompts "script error -50 general Photoshop error, how to solve it?
Unity write multithreading considerations
Unity中.Meta文件作用详解