2019 ICPC-EC final C.Dirichlet k -th root

Dirichlet k -th root

https://ac.nowcoder.com/acm/contest/3732/C


C.Dirichlet k -th root



图片说明



狄利克雷卷积性质,和HDU-5628 Clarke and math这题一样。

复杂度.


#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll;
const int N=1e5+5;
ll f[N],g[N],t[N];
int n,k;
ll ksm(ll a,ll b){
    ll ans=1;
    for(;b>0;b>>=1,a=a*a%mod)if(b&1)ans=ans*a%mod;
    return ans;
}
void cal(ll *a,ll *b){
    memset(t,0,sizeof t);
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            t[j]+=a[i]*b[j/i];
            if(t[j]>=mod)t[j]%=mod;
        }
    }
    for(int i=1;i<=n;i++)a[i]=t[i];
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",&g[i]);
    f[1]=1;
    k=ksm(k,mod-2);
    while(k){
        if(k&1)cal(f,g);
        cal(g,g);
        k>>=1;
    }
    for(int i=1;i<=n;i++)printf("%d%c",f[i]," \n"[i==n]);
}

全部评论

相关推荐

点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务