$dp$。

记$dp[i]$表示$gcd$为$i$的倍数的子序列的方案数。然后倒着推一遍减去倍数的方案数就可以得到想要的答案了。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std; int n;
long long b[100010];
long long a[100010];
long long mod = 1e9+7; int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x; scanf("%d",&x);
for(int j=1;j*j<=x;j++)
{
if(x%j!=0) continue;
a[j]++;
if(x/j!=j) a[x/j]++;
}
} b[0]=1;
for(int i=1;i<=100000;i++) b[i] = (b[i-1]*2)%mod; for(int i=1;i<=100000;i++)
{
a[i] = (b[a[i]]-1+mod)%mod;
} for(int i=100000;i>=1;i--)
{
int tmp = i;
tmp=tmp+i;
while(tmp<=100000)
{
a[i] = (a[i]- a[tmp]+mod)%mod;
tmp=tmp+i;
}
} printf("%lld\n",a[1]); return 0;
}

CodeForces 803F Coprime Subsequences的更多相关文章

  1. Codeforces 803F Coprime Subsequences (容斥)

    Link:http://codeforces.com/contest/803/problem/F 题意:给n个数字,求有多少个GCD为1的子序列. 题解:容斥!比赛时能写出来真是炒鸡开森啊! num[ ...

  2. Codeforces 803F - Coprime Subsequences(数论)

    原题链接:http://codeforces.com/contest/803/problem/F 题意:若gcd(a1, a2, a3,...,an)=1则认为这n个数是互质的.求集合a中,元素互质的 ...

  3. CodeForces - 803F: Coprime Subsequences(莫比乌斯&容斥)

    Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common div ...

  4. F. Coprime Subsequences

    题目链接: F. Coprime Subsequences time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. 【codeforces 803F】Coprime Subsequences

    [题目链接]:http://codeforces.com/contest/803/problem/F [题意] 给你一个序列; 问你这个序列里面有多少个子列; 且这个子列里面的所有数字互质; [题解] ...

  6. Codeforces 660A. Co-prime Array 最大公约数

    A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. codeforces 597C C. Subsequences(dp+树状数组)

    题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standar ...

  8. Codeforces 1132G Greedy Subsequences [线段树]

    洛谷 Codeforces 看到题解那么少就来发一篇吧-- 思路 看完题目一脸懵逼,感觉无从下手. 莫名其妙地想到笛卡尔树,但笛卡尔树好像并没有太大作用. 考虑把笛卡尔树改一下:每个点的父亲设为它的右 ...

  9. Codeforces 915G Coprime Arrays 莫比乌斯反演 (看题解)

    Coprime Arrays 啊,我感觉我更本不会莫比乌斯啊啊啊, 感觉每次都学不会, 我好菜啊. #include<bits/stdc++.h> #define LL long long ...

随机推荐

  1. centos中设置swap交换空间的大小设置和swappiness的比例设置

    首先使用free -m命令查看内存使用情况和swap的大小 关闭swap: 设置swap的大小: bs指的是Block Size,就是每一块的大小.这里的例子是1M,意思就是count的数字,是以1M ...

  2. 使用Eclipse进行SWT编程

    使用Eclipse进行SWT编程 1. 为什么要使用SWT? SWT是IBM开发一套跨平台的GUI开发框架.为什么IBM要创建另一种GUI呢?为什么他们不使用现有的JavaGUI框架呢?要回答这些问题 ...

  3. Vue.js随笔一(Webpack + Vue.js开发准备,含VNM、NPM、Node、Webpack等相关工具)

    想入门工具是必须的,这一章将向大家带来vue.js相关的程序安装步骤. ①首先你需要有一个NVM(一个非常好用的Node版本管理器): 1.NVM下载地址:https://github.com/cor ...

  4. Order By 问题集合

    问题(一):Order By 多个参数排序 在做多字段的排序的时候我们经常会会用到该语句. 所以多参数排序是从左到右的局部排序,修改的范围只有前面参数(几个参数)相同的情况下在排序. select * ...

  5. UVA 1650 Number String

    https://vjudge.net/problem/UVA-1650 题意:D表示比前一个数打,I表示比前一个数小,?表示不确定 给出一个长为n由D I?组成的字符串,问满足字符串大小要求的n+1的 ...

  6. cin.getline()与getline()

    C++中有两个getline函数, cin.getline()与getline()  这两个函数相似,但是 这两个函数分别定义在不同的头文件中.   cin.getline()属于istream流,而 ...

  7. 【CF343D】 Water Tree(树链剖分)

    题目链接 树剖傻逼题,练练手好久没写树剖了. 查询忘记\(pushdown\)抓了好久虫.. 全文手写,一遍过... #include <cstdio> const int MAXN = ...

  8. 35、def func(a,b=[]) 这种写法有什么坑?

    那我们先通过程序看看这个函数有什么坑吧! def func(a,b=[]): b.append(a) print(b) func(1) func(1) func(1) func(1) 看下结果 [1] ...

  9. git创建新分支推送到远程

    1.创建本地分支 git branch 分支名,例如:git branch 2.0.1.20120806 注:2.0.1.20120806是分支名称,可以随便定义.   2.切换本地分支 git ch ...

  10. 第5堂音频课:发音&词串&自学方法示范

    1. 发音怎么练习 我讲解的第5-6节发音课,就像一个有用教练,教你的划水姿势,你学了以后,在床上趴着练练蹬腿,然后,要立刻跳下水去游泳,也就是说,你要去听英语: 请你听一段可可宝贝APP的绘本故事, ...