CF1207F TLE on #5 根号分治
  • 板块灌水区
  • 楼主Katz
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/9/12 21:57
  • 上次更新2023/11/2 21:08:34
查看原帖
CF1207F TLE on #5 根号分治
570194
Katz楼主2023/9/12 21:57

因为学术没人所以发灌水了。

#include<bits/stdc++.h>
#define int long long 
using namespace std;
int q,opt,x,y,a[500010],sum[710][710],ans;//sqrt(500000)=708
main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while(q--)
	{
		cin>>opt>>x>>y;
		if(opt==1)
		{
			a[x]+=y;
			for(int i=1;i<=708;i++) sum[i][x%i]+=y;
		}
		if(opt==2)
		{
			if(x<=708) cout<<sum[x][y%x]<<endl;
			if(x>708)
			{
				ans=0;
				for(int i=y;i<=500000;i+=x) ans+=a[i];
				cout<<ans<<endl;
			}
		}
	}
	return 0;
}
2023/9/12 21:57
加载中...