CF839D Winter is here
题目分析
显然我们不可能直接计算每一个子序列的贡献,而应该计算对于每一个gcd对答案的贡献。
考虑容斥。按照套路:
设\(q(i)\)表示序列\(gcd\)为\(i\)的倍数的序列长度和。
设\(g(i)\)表示序列\(gcd\)为\(i\)的序列对答案的贡献。
设\(f(i)\)表示序列\(gcd\)为\(i\)的序列的容斥系数。
对于\(q(i)\),显然我们可以利用调和级数在\(O(nlogn)\)的时间复杂度下求出\(gcd\)为\(i\)的数的个数。
那么它们形成的子序列的长度和为:\(\sum\limits_{i=0}^ni*\dbinom{n}{i}=n* 2^{n-1}\)
对于\(g(i)\),本题中显然\(g(i)=i\)。
对于\(f(i)\),我们按照套路可以得到:\(g(x)=\sum\limits_{d|x}f(d)\)
这个十分显然的可以直接上莫比乌斯反演。于是得到: \(f(x)=\sum\limits_{d|x}\mu(\frac{x}{d})g(d)\)
这个也很容易利用调和级数在\(O(nlogn)\)的时间复杂度下计算出来。
于是最终答案即为:\(\sum\limits_{i=2}^{10^6}q(i)* f(i)\)
CF839D Winter is here的更多相关文章
- [cf839d]Winter is here容斥原理
题意:给定一个数列${a_i}$,若子序列长度为$k$,最大公约数为$gcd$,定义子序列的权值为$k*\gcd (\gcd > 1)$.求所有子序列的权值和. 答案对10^9+7取模. 解题 ...
- 开发框架Data Abstract和Hydra发布版本Winter 2013
Data Abstract Winter 2013即Data Abstract Version 7.0.73 (Build .1111),Winter 2013版对Data Abstract继续做了以 ...
- 2015 UESTC Winter Training #10【Northeastern Europe 2009】
2015 UESTC Winter Training #10 Northeastern Europe 2009 最近集训都不在状态啊,嘛,上午一直在练车,比赛时也是刚吃过午饭,状态不好也难免,下次比赛 ...
- 2015 UESTC Winter Training #8【The 2011 Rocky Mountain Regional Contest】
2015 UESTC Winter Training #8 The 2011 Rocky Mountain Regional Contest Regionals 2011 >> North ...
- 2015 UESTC Winter Training #7【2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest】
2015 UESTC Winter Training #7 2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest 据 ...
- 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】
2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...
- 2015 UESTC Winter Training #4【Regionals 2008 :: Asia - Tehran】
2015 UESTC Winter Training #4 Regionals 2008 :: Asia - Tehran 比赛开始时电脑死活也连不上WIFI,导致花了近1个小时才解决_(:зゝ∠)_ ...
- Winter(bfs&&dfs)
1084 - Winter PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Winter is ...
- Codeforces 839D Winter is here【数学:容斥原理】
D. Winter is here time limit per test:3 seconds memory limit per test:256 megabytes input:standard i ...
随机推荐
- SpringMVC的数据回现
一.什么是数据回显 数据提交后,如果出现错误,将刚才提交的数据回显到刚才的提交页面. 二.pojo数据回显方法 1.springmvc默认对pojo数据进行回显. pojo数据传入controller ...
- Mybatis基本介绍
Mybatis介绍 1.Mybatis介绍 MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了goog ...
- mysql 优化常用语句
show status;//查询mysql各种状态: show variables like 'long_query_time';//慢查询的限定时间 set long_query_time=1;// ...
- 项目管理系列--好用的代码评审(Code Review)工具
1. Gerrit Gerrit is a web based code review system, facilitating online code reviews for projects us ...
- Git中.gitignore, 忽略追踪
在目录下 创建: .gitignore文件,将不需要被追踪的文件地址, 写在该文件中, 此时git软件就不会追踪列出的文件进行版本同步: windows不允许创建没有文件名的文件,可以用编辑器创建.g ...
- java 类与对象基础整理
之前学习javaSE的时候,没有针对性地对对类与对象的一些基础进行整理,下面这些内容是笔记内容整理后的,希望以后自己可以通过这些博客时常复习! 一.类and对象的基础 类似于类的生命啊,类与对象的关系 ...
- IntelliJ IDEA常用配置
1:IDEA同时打开多个项目: 选择菜单File–Setting-General--->右侧Project Opening选择第一个Open project in new window: 接下来 ...
- ApplicationHost.config文件被破坏导致IIS崩溃
“”Application Host Helper Service 在尝试删除历史目录“C:\inetpub\history\CFGHISTORY_0000000475”时遇到错误.将跳过并忽略此目录 ...
- PAT 1044. Shopping in Mars
#include <cstdio> #include <cstdlib> #include <vector> #include <climits> #i ...
- cf1037E. Trips(图论 set)
题意 题目链接 Sol 倒着考虑!倒着考虑!倒着考虑! 显然,一个能成为答案的子图一定满足,其中任意节点的度数\(>= k\) 那么倒着维护就只用考虑删除操作,如果一个点不合法的话就把它删掉,然 ...