单点更新,
每次查询所有id 为模x余y 的和。
当模数大于sqrt(n)时,暴力,所有满足条件的数,复杂度 n/sqrt(n).
当模数小于sqrt(n)时,预处理出 mo[x][y], 复杂度O n , 数组开到[708][708]
分块思想,即可解决这题。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 5e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int mo[708][708];
int a[M];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int q;
//cout<<sqrt(M)<<endl;
cin>>q;
while(q--)
{
int t,x,y;
cin>>t>>x>>y;
int tp=707;
if(t==1)
{
a[x]+=y;
for(int i=1;i<