题目

注意一下空间限制。

令\(f(n)=\prod\limits_{i=1}^n\prod\limits_{j=1}^nij,g(n)=\prod\limits_{i=1}^n\prod\limits_{j=1}^n(i,j)\)

那么答案就是\(f(n)g(n)^{-2}\).

显然\(f(n)=(n!)^{2n}\)。

而\(g(n)=\prod\limits_{d=1}^nd^{\sum\limits_{i=1}^{\lfloor\frac nd\rfloor}\sum\limits_{j=1}^{\lfloor\frac nd\rfloor}[(i,j)=1]}=\prod\limits_{d=1}^nd^{\sum\limits_{i=1}^{\lfloor\frac nd\rfloor}2\varphi(i)-1}\)。

然后就可以直接做了。

注意一下由于Euler定理指数部分的要对\(P-1\)取模。

#include<bits/stdc++.h>
using namespace std;
const int N=1000007,P=104857601,M=104857600;
int pr[N>>3],m,phi[N];bool f[N];
int inc(int a,int b){return a+=b,a>=M? a-M:a;}
int dec(int a,int b){return a-=b,a<0? a+M:a;}
int mul(int a,int b){return 1ll*a*b%P;}
int sqr(int a){return mul(a,a);}
int power(int a,int k){int r=1;for(;k;k>>=1,a=mul(a,a))if(k&1)r=mul(a,r);return r;}
int fac(int n){int s=1;for(;n;--n)s=mul(s,n);return s;}
int inv(int a){return power(a,P-2);}
int cal1(int n){return power(fac(n),n<<1);}
int cal2(int n)
{
phi[1]=f[1]=1;int ans=1;
for(int i=2,j,x;i<=n;++i)
{
if(!f[i]) pr[++m]=i,phi[i]=i-1;
for(j=1;j<=m&&i*pr[j]<=n;++j)
{
f[x=i*pr[j]]=1;
if(i%pr[j]) phi[x]=phi[i]*phi[pr[j]];
else {phi[x]=phi[i]*pr[j];break;}
}
}
for(int i=2;i<=n;++i) phi[i]=inc(phi[i-1],phi[i]);
for(int i=1;i<=n;++i) phi[i]=dec(inc(phi[i],phi[i]),1);
for(int i=1;i<=n;++i) ans=mul(ans,power(i,phi[n/i]));
return ans;
}
int main(){int n;cin>>n,cout<<mul(cal1(n),sqr(inv(cal2(n))));}

Luogu P5221 Product的更多相关文章

  1. P5221 Product(莫比乌斯反演)

    CYJian的新春虐题赛- 比赛详情 [题目链接] https://www.luogu.org/problemnew/show/P5221 求 \(\prod_{i=1}^{N}\prod_{j=1} ...

  2. 洛谷 P5221 Product 题解

    原题链接 庆祝!第二道数论紫题. 推式子真是太有趣了! \[\prod_{i=1}^n \prod_{j=1}^n \frac{\operatorname{lcm}(i,j)}{\gcd(i,j)} ...

  3. X000011

    P1890 gcd区间 \(\gcd\) 是满足结合律的,所以考虑用 ST 表解决 时间复杂度 \(O((n\log n+m)\log a_i)\) 考虑到 \(n\) 很小,你也可以直接算出所有的区 ...

  4. 【题解】Luogu P2889 [USACO07NOV]挤奶的时间Milking Time

    Luogu P2889 [USACO07NOV]挤奶的时间Milking Time 题目描述 传送门Bessie is such a hard-working cow. In fact, she is ...

  5. uva 11059 maximum product(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK

  6. [LeetCode] Product of Array Except Self 除本身之外的数组之积

    Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...

  7. [LeetCode] Maximum Product Subarray 求最大子数组乘积

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  8. vector - vector product

    the inner product Givens two vectors \(x,y\in \mathbb{R}^n\), the quantity \(x^\top y\), sometimes c ...

  9. 1 Maximum Product Subarray_Leetcode

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

随机推荐

  1. Java web 简单的增删改查程序(超详细)

    就是简单的对数据进行增删改查.代码如下: 1.bean层:用来封装属性及其get set方法 toString方法,有参构造方法,无参构造方法等. public class Bean { privat ...

  2. 19.Python转义字符及用法

    在前面的章节中,我们曾经简单学习过转义字符,所谓转义,可以理解为“采用某些方式暂时取消该字符本来的含义”,这里的“某种方式”指的就是在指定字符前添加反斜杠 \,以此来表示对该字符进行转义. 举个例子, ...

  3. Bzoj3073Journeys

    这不裸的dij吗?来,弄他. 打完以后发现不妙,这数据范围略神奇……算一算,考一场都可能跑不出来.map去重边(成功额外引入log)不怕,交.TLE,54. 这不玩呢吗,把map去了,交.MLE,71 ...

  4. Java 注解指导手册(下)

    9. 自定义注解   正如我们之前多次提及的,可以定义和实现自定义注解.本章我们即将探讨. 首先,定义一个注解:   public @interface CustomAnnotationClass   ...

  5. MQTT 连接服务端失败,报错客户机未连接(32104)

    和同事协同开发项目,在启动项目时偶尔报错连接不到MQTT 服务器. 原因是两个人开发同一个项目,连接MQTT时配置的 client-id 相同,在使用一个client-id连接到MQTT服务器后,再使 ...

  6. [go]os.Open方法源码

    file, err := os.Open("./buf.go") func Open(name string) (*File, error) { return OpenFile(n ...

  7. tfserving 调用deepfm 并预测 java 【参考】

    https://blog.csdn.net/luoyexuge/article/details/79941565?utm_source=blogxgwz8 首先是libsvm格式数据生成java代码, ...

  8. Oracle数据库提高sql查询效率总结

    我们要做到不但会写SQL,还要做到写出性能优良的SQL语句. (1)选择最有效率的表名顺序(只在基于规则的优化器中有效): Oracle的解析器按照从右到左的顺序处理FROM子句中的表名,FROM子句 ...

  9. C# Await

    每次提到异步我都选择绕开,感觉深不可测,最近打算看看异步,但又不愿意看书,网上找了几个视频看,发现传智播客的老师讲异步都不是很深入,关键的问题一笔带过,倒是把我弄糊涂了,印象最深刻的是那个老师说的一句 ...

  10. Ubuntu上挂载源代码,docker容器中共享这个原代码,实现自动部署

    https://www.jianshu.com/p/23465dc86d3e   地址 5.3. 挂载源代码 为了在宿主机上创建.NET Core 项目,这个时候我们就需要在Linux宿主机上安装.N ...