当前位置:网站首页>[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
边栏推荐
- How will the complete NFT platform work in 2022? How about its core functions and online time?
- Interview script of Software Test Engineer
- Similarities and differences of text similarity between Jaccard and cosine
- Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
- MySQL winter vacation self-study 2022 12 (1)
- Version rollback revert don't reset better reset must be forced
- Joint examination of six provinces 2017
- [C language] break and continue in switch statement
- Generic
- system. Exit (0) and system exit(1)
猜你喜欢
NLP pre training technology development
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
Struct in linked list
SPI based on firmware library
Tencent interview: can you find the number of 1 in binary?
Idea set class header comments
Self study software testing. To what extent can you go out and find a job?
Sorry, Tencent I also refused
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
Unity elementary case notes of angry birds Siki college 1-6
随机推荐
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Selenium library 4.5.0 keyword explanation (4)
Briefly understand the operation mode of developing NFT platform
Pair
Interview script of Software Test Engineer
Distributed transaction -- middleware of TCC -- selection / comparison
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
Entropy and full connection layer
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Tencent interview: can you find the number of 1 in binary?
Double efficiency. Six easy-to-use pychar plug-ins are recommended
Struct in linked list
MySQL is installed as a Windows Service
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
12. Go implementation of integer to Roman numeral and leetcode
手机异步发送短信验证码解决方案-Celery+redis
不得不会的Oracle数据库知识点(二)
Report on the construction and development mode and investment mode of sponge cities in China 2022-2028
[PHP basics] session basic knowledge, application case code and attack and defense