AcWing 871. 约数之和
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long LL;
const int N = , mod = 1e9 + ;
int main() {
int n;
cin >> n;
unordered_map<int, int> primes;
while (n -- ) {
int x;
cin >> x;
for (int i = ; i <= x / i; i ++ )
while (x % i == ) {
x /= i;
primes[i] ++ ;
}
if (x > ) primes[x] ++ ;
}
LL res = ;
for (auto p : primes) {
LL a = p.first, b = p.second;//a是底数,b是指数
LL t = ;
while (b -- ) t = (t * a + ) % mod;//求和
res = res * t % mod;
}
cout << res << endl;
return ;
}

AcWing 871. 约数之和的更多相关文章
- 约数之和(POJ1845 Sumdiv)
最近应老延的要求再刷<算法进阶指南>(不得不说这本书不错)...这道题花费了较长时间~(当然也因为我太弱了)所以就写个比较易懂的题解啦~ 原题链接:POJ1845 翻译版题目(其实是AcW ...
- 51NOD 1220 约数之和 [杜教筛]
1220 约数之和 题意:求\(\sum_{i=1}^n \sum_{j=1}^n \sigma_1(ij)\) \[ \sigma_0(ij) = \sum_{x\mid i}\sum_{y\mi ...
- 【动态规划】mr359-最大公约数之和
[题目大意] 选取和不超过S的若干个不同的正整数,使得所有数的约数(不含它本身)之和最大. 输入一个正整数S. 输出最大的约数之和. 样例输入 Sample Input 11 样例输出 Sample ...
- 51Nod 约数之和
1220 约数之和 题目来源: Project Euler 基准时间限制: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∑nj=1∑nd(ij) 题目分析 ...
- POJ1845Sumdiv题解--约数之和
题目链接 https://cn.vjudge.net/problem/POJ-1845 分析 \(POJ\)里的数学题总是这么妙啊 首先有一个结论就是\(A=\prod{ \ {p_i}^{c_i} ...
- 【51nod1220】约数之和
题目 d(k)表示k的所有约数的和.d(6) = 1 + 2 + 3 + 6 = 12. 定义S(N) = ∑1<=i<=N ∑1<=j<=N d(i*j). 例如:S(3) ...
- 51nod1220 约数之和
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1220 $G(n)=\sum\limits_{i=1}^n\sum\lim ...
- ZZNU 正约数之和
#include<stdio.h> #include<string.h> #include<math.h> #include<time.h> #incl ...
随机推荐
- centos8 常用软件
防火墙 GUI版 https://blog.csdn.net/qq_36492368/article/details/80432259 dnf install -y firewall-config d ...
- 改变容器Size后,刷新地图大小。
You need to call the API to update map size. http://dev.openlayers.org/docs/files/OpenLayers/Map-js. ...
- BK: Data mining, Chapter 2 - getting to know your data
Why: real-world data are typically noisy, enormous in volume, and may originate from a hodgepodge of ...
- phpstorm格式化数组
如果我们想要的这样的数组格式的话,可以设置 <?php $arr = array["a" => 0, "b" => 1, "c&qu ...
- JavaScript 闭包浅析
词法作用域 闭包 概念 作用 用法 待续 词法作用域 词法作用域是指一个变量在源码中声明的位置作为它的作用域.同时嵌套的函数可以访问到其外层作用域中声明的变量. 函数中的定义的局部变量只能由函数的内部 ...
- 在电脑上用chrome浏览器调试android手机里的网页代码时,无法看到本地加载的js文件
在需要调试的js文件最顶部加上代码就可以看到了: console.log('haha'); debugger;
- 浅析网页meta标签中X-UA-Compatible属性的使用
今天有一个做开发的朋友突然问你知道很多网站上面加入的X-UA-Compatible属性的意义么?其实这个在以前还专门花了一点时间来验证我自己的想法,结果也确实如自己所预想的那样,八九不离十,当然有一点 ...
- SpringBoot框架---配置
1.更改tomcat的端口号: application.properties 配置文件中, server.port=9090 2.设置上下文路径: server.servlet.context-pat ...
- js获取自定义data属性
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- css样式读取
在做页面改写时,发现外部引入的样式表中一部分的样式起作用,另一部分的样式没有用.无论怎么修改都没有用.最后搜索了下答案,发现是css样式文件与需引入的文件编码不一致.导致样式读取不到或者读取到一半.