标签:its turn http efi bre problem etc int begin
[题目链接] https://www.luogu.org/problemnew/show/P5221
求 \(\prod_{i=1}^{N}\prod_{j=1}^{N}\frac{lcm(i,j)}{gcd(i,j)}\)
[题解] https://tbr-blog.blog.luogu.org/solution-p5221
\[ \begin{aligned} &\ \ \ \ \ \ a+b\&=fsadfasfd\&= \end{aligned} \]
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define ll long long
#define mod 104857601
il int read()
{
re int x=0,f=1;re char c=getchar();
while(c<‘0‘||c>‘9‘) {if(c==‘-‘) f=-1;c=getchar();}
while(c>=‘0‘&&c<=‘9‘) x=x*10+c-48,c=getchar();
return x*f;
}
#define maxn 1000000+5
int n,cnt,ans1=1,prim[80000],ans2=1,pai[maxn];
bool vis[maxn];
il int qpow(int a,ll b)
{
int r=1;
while(b)
{
if(b&1ll) r=1ll*r*a%mod;
b>>=1ll;
a=1ll*a*a%mod;
}
return r;
}
int main()
{
n=read();
pai[1]=1;
for(re int i=2;i<=n;++i)
{
ans1=1ll*ans1*i%mod;
if(!vis[i]) prim[++cnt]=i,pai[i]=i-1;
for(re int j=1;j<=cnt;++j)
{
if(prim[j]*i>n) break;
vis[prim[j]*i]=1;
if(i%prim[j]==0) {pai[i*prim[j]]=pai[i]*prim[j];break;}
pai[i*prim[j]]=pai[prim[j]]*pai[i];
}
}
for(re int i=1;i<=n;++i) pai[i]=pai[i]*2+pai[i-1]%(mod-1);
ans1=qpow(ans1,2*n);
for(re int i=2;i<=n;++i) ans2=1ll*ans2*qpow(i,pai[n/i]-1)%mod;
printf("%d",(1ll*ans1*qpow(1ll*ans2*ans2%mod,mod-2))%mod);
return 0;
}
标签:its turn http efi bre problem etc int begin
原文地址:https://www.cnblogs.com/lizehon/p/10425760.html