fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //
  4. const int mx = 5e5 + 5;
  5. const int S = 700;
  6. //
  7. int q, type, x, y, a[mx];
  8. long long sum[S][S];
  9. //
  10. void process (void)
  11. {
  12. cin >> q;
  13. while (q--)
  14. {
  15. cin >> type >> x >> y;
  16. if (type == 1)
  17. {
  18. a[x] += y;
  19. for (int i = 1; i < S; ++i)
  20. sum[i][x % i] += y;
  21. }
  22. else
  23. {
  24. if (x < S)
  25. cout << sum[x][y];
  26. else
  27. {
  28. long long ans = 0;
  29. //
  30. for (int i = y; i < mx; i += x)
  31. ans += a[i];
  32. cout << ans;
  33. }
  34. cout << '\n';
  35. }
  36. }
  37. }
  38. //
  39. signed main (void)
  40. {
  41. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  42. process();
  43. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty