【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 ...
随机推荐
- 实现h5中radio单击取消与选中
<input type = "radio" id = "raid" name = "raname" checked = 'checke ...
- Python_迭代器、生成器、列表推导式,生成器表达式
1.迭代器 (1)可迭代对象 s1 = ' for i in s1: print(i) 可迭代对象 示例结果: D:\Python36\python.exe "E:/Python/课堂视频/ ...
- WIN10 devtoolsuser
visual studio - UWP: What is the DevToolsUser Password? - Stack Overflowhttps://stackoverflow.com/qu ...
- react购物车demo
import React, { Component } from 'react'; import './App.css'; import {connect} from 'react-redux'; i ...
- React Native之FlatList的介绍与使用实例
React Native之FlatList的介绍与使用实例 功能简介 FlatList高性能的简单列表组件,支持下面这些常用的功能: 完全跨平台. 支持水平布局模式. 行组件显示或隐藏时可配置回调事件 ...
- apache benchmark 的简单安装与测试
1. 下载apache benchmark Copy From https://blog.csdn.net/fyqaccpt96/article/details/43272001 yum instal ...
- windows 10 & 禁用服务.bat
windows 10 & 禁用服务.bat 禁用服务.bat @echo off net stop WSearch net stop wuauserv net start TrustedIns ...
- Dreamweaver怎样用Edge Web Fonts功能
https://jingyan.baidu.com/article/37bce2beb3af6f1002f3a2c9.html
- undefined reference to `cv::VideoCapture
出现opencv链接的问题原因: 1. 路径设置不正确,caffe会优先搜索Makefile.config里面的环境设置 2. anaconda2装的opencv和配置的opencv路径不一致 比如, ...
- Web API 2 自定义默认Identity Table Name
One of the first issues you will likely encounter when getting started with ASP.NET Identity centers ...