CodeForces839D[莫比乌斯反演] Codeforces Round #428 (Div. 2)
/*CodeForces839D[莫比乌斯反演]*/
#include <bits/stdc++.h>
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;
int n, maxa = , mina = 0x3f3f3f3f;
LL m[], F[], f[];
int sum[], a[];
int prime[], vis[], mu[];
void mo_init(int N) {
memset(vis, , sizeof(vis));
mu[] = ;
int cnt = ;
for (int i = ; i < N; i++)
{
if (!vis[i])
{
prime[cnt++] = i;
mu[i] = -;
}
for (int j = ; j < cnt && i * prime[j] < N; j++)
{
vis[i * prime[j]] = ;
if (i % prime[j]) mu[i * prime[j]] = -mu[i];
else
{
mu[i * prime[j]] = ;
break;
}
}
}
}
void solve() {
for (int i = ; i < n; i++) {
for (int j = ; j * j <= a[i]; j++) {
if (a[i] % j == ) {
if (j * j == a[i]) {
sum[j]++;
}
else {
sum[j]++, sum[a[i] / j]++;
}
}
}
}
LL ans = ;
for (int i = ; i <= maxa; i++) {
F[i] = sum[i] * m[sum[i] - ] % MOD;
}
for (int i = ; i <= maxa; i++) {
for (int j = i; j <= maxa; j += i) {
f[i] = (f[i] + mu[j / i] * F[j] % MOD) % MOD;
}
ans = (ans + f[i] * i % MOD) % MOD;
}
printf("%lld\n", ans);
}
void init() {
mo_init();
m[] = 1LL;
for (int i = ; i <= n; i++) {
m[i] = m[i - ] * 2LL % MOD;
}
}
int main() {
scanf("%d", &n);
for (int i = ; i < n; i++) {
scanf("%d", &a[i]);
maxa = max(maxa, a[i]);
mina = min(mina, a[i]);
} init(), solve();
return ;
}
CodeForces839D[莫比乌斯反演] Codeforces Round #428 (Div. 2)的更多相关文章
- CodeForces 839D - Winter is here | Codeforces Round #428 (Div. 2)
赛后听 Forever97 讲的思路,强的一匹- - /* CodeForces 839D - Winter is here [ 数论,容斥 ] | Codeforces Round #428 (Di ...
- CodeForces 839C - Journey | Codeforces Round #428 (Div. 2)
起初误以为到每个叶子的概率一样于是.... /* CodeForces 839C - Journey [ DFS,期望 ] | Codeforces Round #428 (Div. 2) */ #i ...
- CodeForces 839B - Game of the Rows | Codeforces Round #428 (Div. 2)
血崩- - /* CodeForces 839B - Game of the Rows [ 贪心,分类讨论] | Codeforces Round #428 (Div. 2) 注意 2 7 2 2 2 ...
- Codeforces Round #428 (Div. 2) 题解
题目链接:http://codeforces.com/contest/839 A. Arya and Bran 题意:每天给你一点糖果,如果大于8个,就只能给8个,剩下的可以存起来,小于8个就可以全部 ...
- Codeforces Round #428 (Div. 2) D. Winter is here 容斥
D. Winter is here 题目连接: http://codeforces.com/contest/839/problem/D Description Winter is here at th ...
- Codeforces Round #428 (Div. 2)E. Mother of Dragons
http://codeforces.com/contest/839/problem/E 最大团裸题= =,用Bron–Kerbosch算法,复杂度大多博客上没有,维基上查了查大约是O(3n/3) 最大 ...
- 【Codeforces Round #428 (Div. 2) B】Game of the Rows
[Link]:http://codeforces.com/contest/839/problem/B [Description] 给你n排的如题目所示的位置; 同一排中(1,2) 算相邻; (3,4) ...
- 【Codeforces Round #428 (Div. 2) C】Journey
[Link]:http://codeforces.com/contest/839/problem/C [Description] 给一棵树,每当你到一个点x的时候,你进入x的另外一每一个出度的概率都是 ...
- Codeforces Round #428 (Div. 2)A,B,C
A. Arya and Bran time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
随机推荐
- jsHint-静态代码检查工具eclipse中使用
今天介绍一个关于js静态代码的检查工具,此工具可以帮助更好的规范代码的编写形式以及检查错误.由于jslint的分支jsHint有跟多的配置项相对使用也比较方便,依次本文主要介绍jsHint的使用方式. ...
- PostgreSQL数据类型
http://blog.csdn.net/neo_liu0000/article/category/797059 第六章 数据类型 6.1概述 PostgreSQL 提供了丰富的数据类型.用户可以使 ...
- COGS 1215. [Tyvj Aug11] 冗余电网
★ 输入文件:ugrid.in 输出文件:ugrid.out 简单对比时间限制:1 s 内存限制:128 MB TYVJ八月月赛提高组第2题 测试点数目:5 测试点分值:20 --内存 ...
- 2017-3-7-lint183-wood-cut
2017-3-7-lint183-wood-cut 在河之洲 算法 lintcode problem lintcode183 wood cut solution 注意两点 注意边界条件 取的是最大值而 ...
- 【转】HTTP Live Streaming直播(iOS直播)技术分析与实现
HTTP Live Streaming直播(iOS直播)技术分析与实现 不经意间发现,大半年没写博客了,自觉汗颜.实则2012后半年,家中的事一样接着一样发生,实在是没有时间.快过年了,总算忙里偷闲, ...
- Happy Equation
Source: The 10th Shandong Provincial Collegiate Programming Contest 题解: 因为2^p为偶数,所以a,x的奇偶性相同 1.当a为奇数 ...
- JavaScript——图片懒加载
前言 有一个朋友问我这个问题,刚好有时间,现在就简单的写个Demo~ github | https://github.com/wangyang0210/bky/tree/picLoadLazy 内容 ...
- CVE-2011-0065
环境 备注 操作系统 Windows 7 x86 sp1 专业版 漏洞软件 Firefox 版本号:3.6.16 调试器 Windbg 版本号:6.12.0002.633 0x00 漏洞描述 在F ...
- java基础——快速排序
今天又把以前学的快速排序拿出来回忆一下 高快省的排序算法 有没有既不浪费空间又可以快一点的排序算法呢?那就是“快速排序”啦!光听这个名字是不是就觉得很高端呢. 假设我们现在对“6 1 2 7 9 3 ...
- VueJS坎坷之路111---_self.$scopedSlots.default is not a function
VueJs + Element 话不多说,直接贴错: _self.$scopedSlots.default is not a function <el-table stripe border r ...