#include <cstdio>

using namespace std;

typedef long long ll;

const int MAXN = 1e6 + 10;

int n, q;
int cnt[MAXN];
ll a[MAXN];

template <class T>
inline void scan_d(T &ret)
{
    char c;
    ret = 0;
    while ((c = getchar()) < '0' || c > '9');
    while (c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0'), c = getchar();
    }
}

template <class T>
inline void print_d(T x)
{
    if (x > 9)
    {
        print_d(x / 10);
    }
    putchar(x % 10 + '0');
}

int main()
{
    scan_d(n), scan_d(q);
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            cnt[j]++;
        }
    }

    int odr, x, y;
    while (q--)
    {
        scan_d(odr);
        if (odr == 1)
        {
            scan_d(x), scan_d(y);
            for (int i = x, j = 1; i <= n; i += x, j++)
            {
                a[i] += y * cnt[j];
            }
        }
        else
        {
            scan_d(x);
            print_d(a[x]);
            putchar(10);
        }
    }

    return 0;
}

 

相关文章:

  • 2021-06-24
  • 2021-07-16
  • 2022-12-23
  • 2021-06-02
  • 2021-12-05
  • 2021-11-10
  • 2021-07-03
  • 2022-12-23
猜你喜欢
  • 2021-09-25
  • 2022-01-06
  • 2021-08-08
  • 2021-11-20
  • 2021-07-30
  • 2021-08-16
  • 2021-12-28
相关资源
相似解决方案