脑抽了
查看原帖
脑抽了
182231
龙行龘龘楼主2021/1/28 00:14
#include<bits/stdc++.h>
#define For(i,s,e) for(register int i = s;i <= e;++i)
using namespace std;
typedef long long ll;
template <typename T>
inline void read(T &x) {
	char ch = getchar();
	int f = 1;
	x = 0;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = x*10 + ch-'0';
		ch = getchar();
	}
	x*= f;
}
inline void print(ll x) {
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x/10);
	putchar(x%10+'0');
}
const int maxn = 1e6+10;
int n,m;
int a[maxn];
int pls[maxn];
signed main() {
	read(n),read(m);
	For(i,1,n){
		read(a[i]);
	}
	int temp,query;
	For(i,1,m){
		read(temp);
		if(temp == 1){
			register int xxx,yyy;
			read(xxx),read(yyy);
			pls[xxx]+= yyy;
		}else if (temp == 2){
			read(query);
			register int outtt = a[query];
			For(j,1,query/j){
				if(query%j == 0 && pls[j]){
					outtt+= pls[j];
				}
				if(query/j != i && pls[query/j]){
					outtt+= pls[query/j];
				}
			}
			print(outtt);
			putchar('\n');
		}
	}
	return 0;
}

2021/1/28 00:14
加载中...