2021.3.21 哥哥的受难日

T2

题意: ∏ x 1 , x 2 . . . x n ∈ [ 1 , m ] l c m ( x ) gcd ⁡ ( x ) \prod_{x_1,x_2...x_n\in [1,m]}lcm(x)^{\gcd(x)} ∏x1​,x2​...xn​∈[1,m]​lcm(x)gcd(x)

n ≤ 1 0 8 , m ≤ 200000 n\leq 10^8,m\leq 200000 n≤108,m≤200000

∏ i = 1 m ∏ a i ≤ m l c m ( a ) g c d ( a ) [ g c d ( a ) = i ] = ∏ i = 1 m ∏ a i ≤ m i ( i ∗ l c m ( a ) ) i [ g c d ( a ) = 1 ] = ∏ i = 1 m ∏ a i ≤ m i ( i ∗ l c m ( a ) ) i ∑ d ∣ g c d ( a ) μ ( d ) = ∏ i = 1 m ∏ d = 1 m i ∏ a i ≤ m i d ( i ∗ d ∗ l c m ( a ) ) i μ ( d ) = ∏ T = 1 m ∏ a i ≤ m T ( T ∗ l c m ( a ) ) ∑ d ∣ T T d μ ( d ) \rm \prod_{i=1}^m\prod_{a_i\leq m}lcm(a)^{gcd(a)[gcd(a)=i]}\\ =\prod_{i=1}^m\prod_{a_i\leq \frac{m}{i}}(i*lcm(a))^{i[gcd(a)=1]}\\ =\prod_{i=1}^m\prod_{a_i\leq \frac{m}{i}}(i*lcm(a))^{i\sum_{d|gcd(a)}\mu(d)}\\ =\prod_{i=1}^m\prod_{d=1}^{\frac{m}{i}}\prod_{a_i\leq \frac{m}{id}}(i*d*lcm(a))^{i\mu(d)}\\ =\prod_{T=1}^m\prod_{a_i\leq \frac{m}{T}}(T*lcm(a))^{\sum_{d|T}{T\over d}\mu(d)} \\ i=1∏m​ai​≤m∏​lcm(a)gcd(a)[gcd(a)=i]=i=1∏m​ai​≤im​∏​(i∗lcm(a))i[gcd(a)=1]=i=1∏m​ai​≤im​∏​(i∗lcm(a))i∑d∣gcd(a)​μ(d)=i=1∏m​d=1∏im​​ai​≤idm​∏​(i∗d∗lcm(a))iμ(d)=T=1∏m​ai​≤Tm​∏​(T∗lcm(a))∑d∣T​dT​μ(d)

= ∏ T = 1 m ∏ a i ≤ m T ( T ∗ l c m ( a ) ) φ ( T ) = ∏ T = 1 m ( T ⌊ m T ⌋ n ∏ a i ≤ m T l c m ( a ) ) φ ( T ) \rm =\prod_{T=1}^m\prod_{a_i\leq \frac{m}{T}}(T*lcm(a))^{\varphi(T)} \\ =\prod_{T=1}^m(T^{\lfloor\frac{m}{T}\rfloor^n}\prod_{a_i\leq \frac{m}{T}}lcm(a))^{\varphi(T)} \\ =T=1∏m​ai​≤Tm​∏​(T∗lcm(a))φ(T)=T=1∏m​(T⌊Tm​⌋nai​≤Tm​∏​lcm(a))φ(T)

#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define read read1<ll>()
# define Type template<typename T>
Type T read1(){
	T t=0;char k;bool vis=0;
	do (k=getchar())=='-'&&(vis=1);while('0'>k||k>'9');
	while('0'<=k&&k<='9')t=(t<<3)+(t<<1)+(k^'0'),k=getchar();
	return vis?-t:t;
}
# define fre(k) freopen(k".in","r",stdin);freopen(k".out","w",stdout)
int s;
ll qkpow(ll n,int m,int mod){
	ll t=1;
	for(;m;m>>=1,n=n*n%mod)
		(m&1)&&(t=t*n%mod);
	return t;
}int pri[20005],phi[200005];
bool vis[200005];
void prep(const int N=200000){phi[1]=1;
	for(int i=2;i<=N;++i){
		if(!vis[i])pri[++pri[0]]=i,phi[i]=i-1;
		for(int j=1;j<=pri[0]&&pri[j]*i<=N;vis[i*pri[j]]=1,++j)
			if(!(i%pri[j]))phi[i*pri[j]]=phi[i]*pri[j];
			else phi[i*pri[j]]=phi[i]*(pri[j]-1);
	}
}int h[205],n;
# define mod 998244353
ll solve(int m){ll q=1;
	for(int i=1;pri[i]<=m;++i){
		int tot=0,v=1;
		while(1ll*pri[i]*v<=m)
			++tot,v*=pri[i];
		int sum=h[tot]=m/v,t=0;
		for(int j=tot;v/=pri[i],j--;sum+=h[j])
			h[j]=m/v-sum;sum=qkpow(h[0],n,mod-1);
		for(int j=1;j<=tot;++j){
			h[j]+=h[j-1];
			int tv=qkpow(h[j],n,mod-1)-sum+(mod-1);tv+1>=mod&&(tv-=mod-1);
			t=(t+1ll*j*tv)%(mod-1);
			sum=(sum+tv)%(mod-1);
		}q=q*qkpow(pri[i],t,mod)%mod;
	}
	return q;
}
int main(){
	fre("lg");
	prep();
	n=read;s=read;
	ll ans=1;
	for(int T=1;T<=s;++T){
		ll t=qkpow(qkpow(T,qkpow(s/T,n,mod-1),mod)*solve(s/T)%mod,phi[T],mod);
		ans=ans*t%mod;
	}cout<<ans;
	return 0;
}
上一篇:[清华集训2017]生成树计数


下一篇:最全的数据库笔记