51nod1355
没啥意思的板子题。
首先,众所周知,
\]
所以考虑将 \(\operatorname{lcm}\) 转化为 \(\gcd\)。
\(\min-\max\) 容斥指出,
\]
于是有推论
\]
(对每个质因子做一次 \(\min-\max\) 反演)
于是只用计算每个 \(v=\gcd\limits_{a\in T}a\),其 \(v\) 的幂次的贡献。
考虑到这需要 \(\gcd\) 卷积。
不妨设有全集 \(U\),满足其为所有(考虑范围内的)数的倍数。
这样,我们即可用 \(\gcd\) 卷积描述其为
\]
众所周知这个形式可以使用 CF449D 的技巧,用 Dirichlet 前缀和可以对其优化。
然后就做完了。
核心代码很短。
const ullt Mod=1e9+7;
typedef ConstMod::mod_ullt<Mod>modint;
typedef std::vector<modint>modvec;
int Cnt[2000005];
bol Gone[2000005];
modint F[2000005];
int main()
{
#ifdef MYEE
freopen("QAQ.in","r",stdin);
// freopen("QAQ.out","w",stdout);
#endif
uint n;scanf("%u",&n);
for(uint i=0,v;i<n;i++)
scanf("%u",&v),Cnt[v]++;
for(uint i=2;i<=1000000;i++)if(!Gone[i]){
for(uint j=1000000/i*i;j;j-=i)
Cnt[j/i]+=Cnt[j],Gone[j]=1;
Gone[i]=0;
}
F[1]=1;
for(uint i=1;i<=1000000;i++)
Cnt[i]=(bol)Cnt[i],F[i+1]=F[i]+F[i-1];
for(uint i=2;i<=1000000;i++)if(!Gone[i])
for(uint j=i;j<=1000000;j+=i)
Cnt[j/i]-=Cnt[j];
modint ans(1);
for(uint i=1;i<=1000000;i++)
ans*=Cnt[i]>=0?F[i]^Cnt[i]:F[i]^(((Mod-2)*-Cnt[i])%(Mod-1));
ans.println();
return 0;
}
51nod1355的更多相关文章
- 【51nod1355】斐波那契的最小公倍数(min-max容斥)
[51nod1355]斐波那契的最小公倍数(min-max容斥) 题面 51nod 题解 显然直接算还是没法算的,所以继续考虑\(min-max\)容斥计算. \[lcm(S)=\prod_{T\su ...
- [51nod1355] 斐波那契的最小公倍数
Description 给定 \(n\) 个正整数 \(a_1,a_2,...,a_n\),求 \(\text{lcm}(f_{a_1},f_{a_2},...,f_{a_n})\).其中 \(f_i ...
随机推荐
- vue table刷新单行数据
1.给el-table加上标记方法 <el-table v-loading="loading" :data="tagList1" @selection-c ...
- ubuntu下升级gcc11环境
使用ppa源升级 官网地址: https://launchpad.net/ ppa toolchan/test地址: https://launchpad.net/~ubuntu-toolchain-r ...
- 复习第二点-2.基于注解的helloworld
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="htt ...
- VMvare虚拟机的安装及新建虚拟机(一)
a:hover { color: rgba(255, 102, 0, 1) } 一.VMvare虚拟机的安装 1.首先双击--你下载的安装包,这里我分享百度云盘,供大家下载:http://pan.ba ...
- oracle的dblink创建连接查询及使用
https://www.cnblogs.com/muhai/p/15527463.html https://www.cnblogs.com/leipei2352/archive/2011/04/21/ ...
- 在sublime text 3中编译javascript
1.整理步骤: 1).安装node.js: 2).配置js编译系统: 2.过程 1).先是按照网上的方法,在配置的时候输入如下内容: {"cmd": ["node&quo ...
- python自动化-取消"Chrome正受到自动软件的控制"提示
chrome浏览器V78及以上版本解决做法,代码如下: from selenium import webdriver chrome_options = webdriver.ChromeOptions( ...
- LogAgent —— etcd+kafka+zookeeper+go实现实时读取日志发送到kafka,并实现热加载配置读取的日志路径
工具包目录结构: .├── conf│ ├── logAgent.ini│ └── logAgentConfig.go├── etcd│ └── etcd.go├── kafka│ └ ...
- idea字体的大小设置
idea字体大小设置 两个方法,滚轮.固定大小设置 固定字体大小 file--settings--editor--font--size 修改为需要大小字号,例如20,点击ok 菜单栏的大小设置也差不多 ...
- c、c++字符串匹配
fnmatch(pattern, str, FNM_NOESCAPE) 头文件:https://github.com/gcc-mirror/gcc/blob/master/include/fnma ...