H-Convolution
x⨂y=xygcd(x,y)x\bigotimes y=\frac{xy}{\gcd(x,y)}x⨂y=gcd(x,y)xy
下面大佬题解推🦁
Ultraman-Ace题解
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template <class T=int> T rd()
{T res=0;T fg=1;char ch=getchar();while(!isdigit(ch)) {if(ch=='-') fg=-1;ch=getchar();}while( isdigit(ch)) res=(res<<1)+(res<<3)+(ch^48),ch=getchar();return res*fg;
}
const ll mod=998244353;
ll qmi(ll a,ll b)
{ll v=1;while(b){if(b&1) v=v*a%mod;b>>=1;a=a*a%mod;}return v;
}
const int N=1000010;
ll n,c;
ll a[N],b[N];
ll pw[N],sum[N];
int main()
{n=rd<ll>(),c=rd<ll>();for(int i=1;i<=n;i++) a[i]=rd<ll>();for(int i=1;i<=n;i++) pw[i]=qmi(i,c);for(int i=1;i<=n;i++){for(int j=1;i*j<=n;j++)sum[j]=(sum[j-1]+a[i*j]*pw[j]%mod)%mod;for(int j=1;i*j<=n;j++)if(__gcd(i,j)==1) {int u=n/max(i,j);b[i*j]=(b[i*j]+sum[u]*pw[j]%mod)%mod;}}ll ans=0;for(int i=1;i<=n;i++) ans^=b[i];printf("%lld\n",ans);return 0;
}