#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. Android——搜索传统蓝牙设备

    一,主布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro ...

  2. AD-Powershell for Active Directory Administrators

    Table of Contents   Computer object commands Group object commands Organizational Unit (OU) commands ...

  3. Delphi7目录结构----初学者参考

    打开Delphi的安装目录,如C:\Program Files\Borland\Delphi7,你将会看到目录下包含了一些文件和文件夹: ²        Source:存放的是Delpi提供的所有源 ...

  4. Java 图像处理框架-Marvin

    网上看到,摘录过来的,暂时还没涉足这方面的东西 Marvin 1.4.5 的插件接口支持处理多个图像作为输入,新的插件可通过多个图片来确认背景,新的插件可使用多个图片来合并相同场景. Marvin 是 ...

  5. Django admin源码剖析

    单例模式 单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在.当你希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场. ...

  6. 「日常训练」Our Tanya is Crying Out Loud (CFR466D2B)

    题意(Codeforces 940B) 对一个数字$x$,你有两个决策:花费$A$减一.或花费$B$除以$k$(但必须可以除尽).问使之到$1$的最少花费. 分析 贼鸡儿简单,但我花式犯蠢……如果除不 ...

  7. Qt_C++交换两个数

    在编程过程中,交换两个数是我用常用的 ,这里做下简单的搬运 bool Widget::swap(int a, int b) { int temp =a; a= b; b = temp; } 这种方式其 ...

  8. 树莓派putty远程登录windows

    刚买树莓派的你,还在为要不要购买昂贵的屏幕而纠结吗?看完本博客学会远程登录,妈妈再也不用担心我的学习... 首先我们要知道树莓派的官方推荐系统是raspbian 很建议安装16年9月份的,其他的总是这 ...

  9. Fluentd插件使用方法

    这里主要介绍从MongoDB同步数据到ODPS.ruby环境的搭建以及fluent_plugin_mongo_odps插件的安装.1.准备工作1.1安装环境要求Ruby 2.1以上Gem 2.4.5以 ...

  10. LeetCode - 66. Plus One(0ms)

    Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The ...