1.prefix 前缀和数组 p[i] = p[i-1] + a[i];
优点:便于数组查找
123456789101112131415161718192021222324//https://www.starrycoding.com/problem/7#include <bits/stdc++.h>using namespace std;using ll =long long;const int N = 1e5+9;ll a[N],p[N];int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int T;cin >> T; while(T--){ ll n,q;cin >> n >> q; for(int i = 1;i <= n;i++){ cin >> a[i]; } for(int i = 1;i <= n;i++){ p[i] = p ...