当前位置:网站首页>[prefix and notes] prefix and introduction and use
[prefix and notes] prefix and introduction and use
2022-07-04 00:34:00 【muse_ age】
The prefix and :( Before similar series n Xiang He )
use sum Before array record i Xiang He
sum[i]=a[0]+a[1]...+a[i]
purpose : You can quickly find the interval 【i,j】 Sum of all numbers

Subtract the two formulas to prove
/* Prefixes and notes :
1. It is known that num Array , Apply for another one of the same size sum Array
2. For the sake of calculation ,num Array and sum Arrays are all subscript 1 For the first element
3. Edge input , Edge update sum Array
sum[0]=0;
for(int i=1;i<=n;i++)
{
cin>>num[i];
sum[i]=sum[i-1]+a[i];
}
4. seek sum[i..j]( That is to say i The number to the first j The number and )
sum[i..j]=sum[j]-sum[i-1]
If i be equal to 1,sum[1..j]=sum[j]-sum[0]=sum[j]
therefore ,num&&sum Array from 1 Start and sum[0]=0
边栏推荐
- From functional testing to automated testing, how did I successfully transform my salary to 15K +?
- Att & CK actual combat series - red team actual combat - V
- 打印菱形图案
- HR disgusted interview behavior
- Suggestions for improving code quality
- What is the Valentine's Day gift given by the operator to the product?
- Smart fan system based on stm32f407
- [about text classification trick] things you don't know
- Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
- 1214 print diamond
猜你喜欢

On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it

功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
![[Mongodb] 2. Use mongodb --------- use compass](/img/d5/0eb7dd4c407fbf2e9ba1b175f5424d.jpg)
[Mongodb] 2. Use mongodb --------- use compass
![[GNN] hard core! This paper combs the classical graph network model](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[GNN] hard core! This paper combs the classical graph network model

Is user authentication really simple

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival

Is it really possible that the monthly salary is 3K and the monthly salary is 15K?

老姜的特点

MySQL is installed as a Windows Service

STM32 GPIO CSDN creative punch in
随机推荐
【leetcode】374. Guess the size of the number
想请教一下,十大劵商如何开户?在线开户是安全么?
[CSDN Q & A] experience and suggestions
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
Anomalies seen during the interview
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
[Mongodb] 2. Use mongodb --------- use compass
How to trade spot gold safely?
Global and Chinese market of melting furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
Analysis on the scale of China's smart health industry and prediction report on the investment trend of the 14th five year plan 2022-2028 Edition
P1629 postman delivering letter
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
For loop
From functools import reduce -- see the use of reduce function from typical examples
CSP window
Vscode regular match replace console log(.*)
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools