#include <cstdio>

using namespace std;

typedef long long ll;

const int MAXN = 1e6 + ;

int n, q;
int cnt[MAXN];
ll a[MAXN]; template <class T>
inline void scan_d(T &ret)
{
char c;
ret = ;
while ((c = getchar()) < '' || c > '');
while (c >= '' && c <= '')
{
ret = ret * + (c - ''), c = getchar();
}
} template <class T>
inline void print_d(T x)
{
if (x > )
{
print_d(x / );
}
putchar(x % + '');
} int main()
{
scan_d(n), scan_d(q);
for (int i = ; i <= n; i++)
{
for (int j = i; j <= n; j += i)
{
cnt[j]++;
}
} int odr, x, y;
while (q--)
{
scan_d(odr);
if (odr == )
{
scan_d(x), scan_d(y);
for (int i = x, j = ; i <= n; i += x, j++)
{
a[i] += y * cnt[j];
}
}
else
{
scan_d(x);
print_d(a[x]);
putchar();
}
} return ;
}

51Nod-1586-约数和的更多相关文章

  1. 51nod - 1586 - 约数和 - 打表 - 思维

    https://www.51nod.com/Challenge/Problem.html#problemId=1586 一眼看过去居然一点思路都没有的,一言不合就打表,打贡献表. #include & ...

  2. 51NOD 1220 约数之和 [杜教筛]

    1220 约数之和 题意:求\(\sum_{i=1}^n \sum_{j=1}^n \sigma_1(ij)​\) \[ \sigma_0(ij) = \sum_{x\mid i}\sum_{y\mi ...

  3. [51Nod 1220] - 约数之和 (杜教筛)

    题面 令d(n)d(n)d(n)表示nnn的约数之和求 ∑i=1n∑j=1nd(ij)\large\sum_{i=1}^n\sum_{j=1}^nd(ij)i=1∑n​j=1∑n​d(ij) 题目分析 ...

  4. 51nod 1220 约数之和【莫比乌斯反演+杜教筛】

    首先由这样一个式子:\( d(ij)=\sum_{p|i}\sum_{q|j}[gcd(p,q)==1]\frac{pj}{q} \)大概感性证明一下吧我不会证 然后开始推: \[ \sum_{i=1 ...

  5. 51nod1586 约数和

    果然我自己写的读入优化naive!...换题目给的读入优化就A了...话说用visual交快了好多啊... const int BufferSize=1<<16; char buffer[ ...

  6. 51nod 约数和(数论)

    题目链接: 约数和 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 有三个下标从1到n的数组a.b.c. a数组初始全为0. b[i]=∑j|ia[j] c[i]=∑j|ib[j] ...

  7. 51NOD 1584 加权约数和 [莫比乌斯反演 转化 Trick]

    1584 加权约数和 题意:求\(\sum_{i=1}^{N} \sum_{j=1}^{N} {\max(i,j)\cdot \sigma(i\cdot j)}\) 多组数据\(n \le 10^6, ...

  8. [51Nod 1584] 加权约数和

    Description 在整理以前的试题时,他发现了这样一道题目:"求 \(\sum\sigma(i)\),其中 \(1≤i≤N\),\(σ(i)\) 表示 \(i\) 的约数之和.&quo ...

  9. 51nod 1584加权约数和

    学到了好多东西啊这题... https://blog.csdn.net/sdfzyhx/article/details/72968468 #include<bits/stdc++.h> u ...

  10. 51Nod 约数之和

                              1220 约数之和                                  题目来源: Project Euler 基准时间限制:3 秒 ...

随机推荐

  1. 如何在windows“我的电脑”中添加快捷文件夹

    如图所示,windows中打开“我的电脑”时,原来有6个默认的文件夹,访问非常便捷,自己想再增加,可以使用“ThisPCTweaker”即可完成 操作如下图,不多解释,简单操作: 文件下载:http: ...

  2. C++11中initializer lists的使用

    Before C++11,there was no easy way to do things like initialize a std::vector or std::map(or a custo ...

  3. Gradle 设置本地meaven

    repositories { maven { url uri("F:\\meaven")} }

  4. c++ constructor, copy constructor, operator =

    // list::push_back #include <iostream> #include <list> class element{ private: int numbe ...

  5. FJOI 2019 游记

    (FJOI 2019 滚粗记) Day 0 早上刷了一些水题,然后就上路了. (画图3D好好玩) 来得晚只有十几分钟时间看考场,于是连试机题都没有Ak. Day 1 果然我还是太菜了 走过来的时候再讨 ...

  6. Percona-Tookit工具包之pt-find

      Preface       We used to use "find" command in linux or AIX when we need to get a certai ...

  7. ibdata1文件损坏时恢复InnoDB单表测试

      Preface       ibdata1 file is a shared system tablespace of innodb engine.Although we always set v ...

  8. 玩玩自动化测试之selenium篇

    现如今社会科技发展太快了,纯功能点点点已经落后别人好几条街了,所以为了让自己多点职业生涯年限,得挺起肩,傲起头.自动化测试,其本质是用代码程序测试程序,所以其实第一步应该学好编程语言,后再自己开发自动 ...

  9. HTTP 知新

    REST 先从 REST 的角度来看看 HTTP 协议规范, URL:需要操作的对象,也就是资源 HTTP method:我要对该对象做什么(POST 增.DELETE 删.GET 查.PUT 和 P ...

  10. HDU 4735 Little Wish~ lyrical step~(DLX搜索)(2013 ACM/ICPC Asia Regional Chengdu Online)

    Description N children are living in a tree with exactly N nodes, on each node there lies either a b ...