【hdu 5628】Clarke and math (Dirichlet卷积)
题意
Given f(i),1≤i≤n, calculate
\(\displaystyle g(i) = \sum_{i_1 \mid i} \sum_{i_2 \mid i_1} \sum_{i_3 \mid i_2} \cdots \sum_{i_k \mid i_{k-1}} f(i_k) \text{ mod } 1000000007 \quad (1 \le i \le n)\)
题解
Dirichlet convolution -wiki
别人的题解
恒等函数1(n)=1。
那么\(\sum_{i_k \mid i_{k-1}} f(i_k)\) 就是\(f(i_k)\)与\(1(\frac {i_{k-1}} {i_k})\) 的狄利克雷卷积
然后再和$ 1(\frac {i_{k-2}} {i_{k-1}})$卷积。。。
再用的狄利克雷卷积满足交换律,所以就是 \(g(i)=\sum_{j|i}f(j)1^k\)
代码
const int N=201000;
int n,k;
ll tmp[N],x[N],f[N],ans[N];
void dirichlet(ll *ans, ll *x){
mem(tmp,0);
rep(i,1,sqrt(n)+1){
tmp[i*i]+=ans[i]*x[i]%mod;
rep(j,i+1,n/i+1){
tmp[i*j]+=ans[i]*x[j]%mod;
tmp[i*j]+=ans[j]*x[i]%mod;
}
}
rep(i,1,n+1)
ans[i]=tmp[i]%mod;
}
void qpow(){
for(;k;k>>=1,dirichlet(x, x))
if(k&1) dirichlet(ans, x);
}
int main() {
int t;
sf(t);
while(t--){
sf(n);sf(k);
rep(i,1,n+1){
sfl(f[i]);
ans[i]=0;
x[i]=1;
}
ans[1]=1;
qpow();
dirichlet(ans, f);
rep(i,1,n+1)printf("%lld%c",ans[i],i==n?'\n':' ');
}
return 0;
}
【hdu 5628】Clarke and math (Dirichlet卷积)的更多相关文章
- HDU 5628 Clarke and math Dirichlet卷积+快速幂
题意:bc round 72 中文题面 分析(官方题解): 如果学过Dirichlet卷积的话知道这玩意就是g(n)=(f*1^k)(n), 由于有结合律,所以我们快速幂一下1^k就行了. 当然,强行 ...
- HDU.5628.Clarke and math(狄利克雷卷积 快速幂)
\(Description\) \[g(i)=\sum_{i_1|i}\sum_{i_2|i_1}\sum_{i_3|i_2}\cdots\sum_{i_k|i_{k-1}}f(i_k)\ mod\ ...
- HDU 5628 Clarke and math——卷积,dp,组合
HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...
- HDU 5628 Clarke and math dp+数学
Clarke and math 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5628 Description Clarke is a patient ...
- 积性函数与Dirichlet卷积
转载自https://oi-wiki.org/math/mobius/ 积性函数 定义 若 $gcd(x,y)=1$ 且 $f(xy)=f(x)f(y)$,则 $f(n)$ 为积性函数. 性质 若 $ ...
- 『简单积性函数和dirichlet卷积』
简单积性函数 在学习欧拉函数的时候,相信读者对积性函数的概念已经有了一定的了解.接下来,我们将相信介绍几种简单的积性函数,以备\(dirichlet\)卷积的运用. 定义 数论函数:在数论上,对于定义 ...
- Dirichlet 卷积学习笔记
Dirichlet 卷积学习笔记 数论函数:数论函数亦称算术函数,一类重要的函数,指定义在正整数集上的实值或复值函数,更一般地,也可把数论函数看做是某一整数集上定义的函数. 然而百科在说什么鬼知道呢, ...
- [基本操作] Mobius 反演, Dirichlet 卷积和杜教筛
Dirichlet 卷积是两个定义域在正整数上的函数的如下运算,符号为 $*$ $(f * g)(n) = \sum_{d|n}f(d)g(\frac{n}{d})$ 如果不强调 $n$ 可简写为 $ ...
- HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3
比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...
随机推荐
- hibernate坑边闲话2
threw exception [Request processing failed; nested exception is org.springframework.orm.hibernate5.H ...
- PYTHON访问数据库
PYTHON DB API(规范)框架 可以一次编写同时访问MySql\ Oracle \SQLServer...不同的数据库服务器:统一接口程序的混乱. 1.连接访问:connection(高速路) ...
- openstack-KVM-vCPU
一.KVM基础功能 (1)支持 硬件支持 VT-x VT-d 系统支持 kernel > 3.5 (2)计算机系统的子系统 CPU 处理器 Memory 内存 Storage 存储 Networ ...
- ElastichSearch漏洞
Ubuntu服务器被黑经历(ElastichSearch漏洞) 起因 最近我们的一台Ubuntu阿里云服务器一直提示有肉鸡行为,提示了好几天,开始并没有关注,然后连续几天后发现应该是个大问题啊.很可能 ...
- use redis instance in docker hub
redis - Docker Hubhttps://hub.docker.com/_/redis
- Java Profiling & Profilers
A Guide to Java Profilers | Baeldunghttps://www.baeldung.com/java-profilers 常用 Java Profiling 工具的分析与 ...
- Tomcat Cluster
Tomcat群集配置| Tomcat集群| MuleSofthttps://www.mulesoft.com/tcat/tomcat-cluster Tomcat Clustering - A Ste ...
- 【Python3练习题 025】 一个数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同
[Python练习题 025] 一个5位数,判断它是不是回文数.即12321是回文数,个位与万位相同,十位与千位相同 x = input('请输入任意位数的数字:') if x == x[::-1]: ...
- IdentityServer4【QuickStart】之使用asp.net core Identity
使用asp.net core Identity IdentityServer灵活的设计中有一部分是可以将你的用户和他们的数据保存到数据库中的.如果你以一个新的用户数据库开始,那么,asp.net co ...
- [转帖]HTTP 头部解释
HTTP 头部解释 https://www.cnblogs.com/poissonnotes/p/4844014.html 之前看的太粗了 同事闻起来 referer 才知道自己所知甚少.. ==== ...