题目:https://codeforces.com/problemset/problem/1207/F
给你两种操作:
1 x, y—— 对第x个数加y
2 x, y—— 计算[1,500000]中模x等于y的那些位的和
思路:
数据大小500000,开根号为710,所以如果模的数超过710,那么循环节就大于710,时间复杂度是根号n的,如果模数小于710我们就先预处理出来就好了。
#include <iostream>
#include<cstdio>
#include<fstream>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int dp[750][750];
int num[500005];
int main()
{
int q;
scanf("%d", &q);
int op, x, y;
while(q--)
{
scanf("%d%d%d", &op, &x, &y);
if(op == 1)
{
for(int i = 1; i <= 710; i++)
{
dp[i][x%i]+=y;