传送门

拆开变成

\[\prod_{i=1}^{n}\sigma_0(i)^{\mu(i)}\prod_{i=1}^{n}\sigma_0(i)^{i}
\]

考虑 \(\prod_{i=1}^{n}\sigma_0(i)^{\mu(i)}\)

运用 \(\mu\) 的性质,设 \(c(i)\) 表示 \(i\) 的质数因子个数

那么就是

\[\prod_{i=1}^{n}2^{\mu(i)c(i)}=2^{\sum_{i=1}^{n}\mu(i)c(i)}
\]

只需要设

\(f(x,j)\) 表示 \(1\) 到 \(x\) 最小质因子大于等于第 \(j\) 个质数的合数的 \(\mu(i)c(i)\) 的和

\(g(x,j)\) 表示 \(1\) 到 \(x\) 最小质因子大于等于第 \(j\) 个质数的合数的 \(\mu(i)\) 的和

预处理出 \(cntp(i)\) 表示 \(1\) 到 \(x\) 的质数个数就可以递推了

这一部分直接 \(min25\) 筛即可

考虑 \(\prod_{i=1}^{n}\sigma_0(i)^{i}\)

分开考虑每个质数的贡献

设 \(s(n,p,k)\) 表示 \(1\) 到 \(n\) 中只含有 \(p^k\) 这个因子不含 \(p^i,i\ne k\) 的数的和

设 \(P\) 为质数集合

那么

\[\prod_{i=1}^{n}\sigma_0(i)^{i}=\prod_{p\in P}\prod_{k=1}(k+1)^{s(n,p,k)}
\]

设 \(Sum(x)=\sum_{i=1}^{x}i\)

那么

\[s(n,p,k)=p^kSum(\lfloor\frac{n}{p^k}\rfloor)-p^{k+1}Sum(\lfloor\frac{n}{p^{k+1}}\rfloor)
\]

当 \(p\le \sqrt{n}\) 的时候直接暴力计算

当 \(p > \sqrt{n}\) 的时候,显然 \(k\) 最多就是 \(1\)

那么

\[s(n,p,k)=pSum(\lfloor\frac{n}{p}\rfloor)
\]

\(min25\) 筛预处理出 \(S(x)\) 表示 \(1\) 到 \(x\) 的质数的和,然后数论分块即可

注意常数优化QwQ

# include <bits/stdc++.h>
using namespace std;
typedef long long ll; const ll mod(1e12 + 39);
const ll phi(1e12 + 38);
const int maxn(1e6 + 5); inline ll Mul1(ll x, ll y) {
register ll ret = x * y - (ll)((long double)x / mod * y + 0.5) * mod;
return ret < 0 ? ret + mod : ret;
} inline ll Mul2(ll x, ll y) {
register ll ret = x * y - (ll)((long double)x / phi * y + 0.5) * phi;
return ret < 0 ? ret + phi : ret;
} inline ll Pow(ll x, ll y) {
register ll ret = 1;
for (; y; y >>= 1, x = Mul1(x, x))
if (y & 1) ret = Mul1(ret, x);
return ret;
} inline void Inc1(ll &x, ll y) {
x = x + y >= mod ? x + y - mod : x + y;
} inline void Inc2(ll &x, ll y) {
x = x + y >= phi ? x + y - phi : x + y;
} inline ll Dec1(ll x, ll y) {
return x - y < 0 ? x - y + mod : x - y;
} inline ll Dec2(ll x, ll y) {
return x - y < 0 ? x - y + phi : x - y;
} int test, pr[maxn], tot, d, id1[maxn], id2[maxn], cnt;
ll n, val[maxn], cntp[maxn], f[maxn], g[maxn], s[maxn], sp[maxn];
bitset <maxn> ispr; # define ID(x) ((x) <= d ? id1[x] : id2[n / (x)]) inline ll Sum1(ll x) {
return (x & 1) ? Mul1(x, (x + 1) / 2) : Mul1(x / 2, x + 1);
} inline ll Sum2(ll x) {
return (x & 1) ? Mul2(x, (x + 1) / 2) : Mul2(x / 2, x + 1);
} inline ll GetSum(ll x, ll v1, ll v2) {
return Dec2(Mul2(v1, Sum2(x / v1)), Mul2(v2, Sum2(x / v2)));
} inline void Solve() {
while (cnt) f[cnt] = g[cnt] = 0, cnt--;
register ll i, j, id, ans1, ans2, v, ret, lst, cur;
for (d = sqrt(n), i = 1; i <= n; i = j + 1) {
j = n / (n / i), val[++cnt] = n / i;
val[cnt] <= d ? id1[val[cnt]] = cnt : id2[j] = cnt;
cntp[cnt] = val[cnt] - 1, s[cnt] = Sum2(val[cnt]) - 1;
}
for (i = 1; i <= tot && pr[i] <= n / pr[i]; ++i)
for (j = 1; j <= cnt && pr[i] <= val[j] / pr[i]; ++j) {
id = ID(val[j] / pr[i]), cntp[j] -= cntp[id] - i + 1;
Inc2(s[j], Mul2(pr[i], Dec2(sp[i - 1], s[id])));
}
for (--i; i; --i)
for (j = 1; j <= cnt && pr[i] <= val[j] / pr[i]; ++j) {
id = ID(val[j] / pr[i]);
v = Dec2(cntp[id] - i, g[id]), Inc2(g[j], v);
Inc2(v, cntp[id] - i), Inc2(f[j], Dec2(v, f[id]));
}
for (i = 1; i <= cnt; ++i) Inc2(f[i], phi - cntp[i]);
ans1 = Pow(2, f[ID(n)]), ans2 = 1;
for (i = 1; i <= tot && pr[i] <= n / pr[i]; ++i)
for (j = 1, v = pr[i]; v <= n; v = v * pr[i], ++j) ans2 = Mul1(ans2, Pow(j + 1, GetSum(n, v, v * pr[i])));
for (lst = sp[i - 1], ret = 0, i = pr[i]; i <= n; i = j + 1) {
j = n / (n / i);
Inc2(ret, Mul2(Dec2(cur = s[ID(j)], lst), Sum2(n / i))), lst = cur;
}
ans2 = Mul1(ans2, Pow(2, ret)), printf("%lld\n", Mul1(ans1, ans2));
} int main() {
register int i, j;
ispr[1] = 1;
for (i = 1; i < maxn; ++i) {
if (!ispr[i]) pr[++tot] = i, sp[tot] = (sp[tot - 1] + i) % phi;
for (j = 1; j <= tot && i * pr[j] < maxn; ++j) {
ispr[i * pr[j]] = 1;
if (!(i % pr[j])) break;
}
}
scanf("%d", &test);
while (test) scanf("%lld", &n), Solve(), --test;
return 0;
}

51NOD1965:奇怪的式子的更多相关文章

  1. [51nod1965]奇怪的式子

    noteskey 怎么说,魔性的题目...拿来练手 min_25 正好...吧 首先就是把式子拆开来算贡献嘛 \[ANS=\prod_{i=1}^n \sigma_0(i)^{\mu(i)} \pro ...

  2. 51nod1965. 奇怪的式子(min_25筛)

    题目链接 http://www.51nod.com/Challenge/Problem.html#!#problemId=1965 题解 需要求的式子显然是个二合一形式,我们将其拆开,分别计算 \(\ ...

  3. 【51nod1965】奇怪的式子

    Portal --> 51nod1965 Solution 怎么说呢..这题..做的有点痛苦.. 首先看这个式子长得..比较奇怪,指数里面那个加号有点烦人,而且这个函数不是一个积性函数也有点烦人 ...

  4. 【51NOD1965】奇怪的式子 min_25筛

    题目描述 给你\(n\),求 \[ \prod_{i=1}^n{\sigma_0(i)}^{i+\mu(i)} \] 对\({10}^{12}+39\)取模. \(\sigma_0(i)\)表示约数个 ...

  5. 51nod 1965 奇怪的式子 —— min_25筛

    题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1965 推式子就同这里:https://www.cnblogs.com/yoyo ...

  6. 51nod 1965 奇怪的式子——min_25筛

    题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1965 考虑 \( \prod_{i=1}^{n}\sigma_0^i \) \ ...

  7. light oj 1236 分解质因数

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70017#problem/H 题意:求满足1<=i<=j<=n ...

  8. BZOJ 1045 糖果传递

    奇怪的式子.最后发现取中位数. #include<iostream> #include<cstdio> #include<cstring> #include< ...

  9. BZOJ3456城市规划

    题目描述 刚刚解决完电力网络的问题, 阿狸又被领导的任务给难住了.刚才说过, 阿狸的国家有n个城市, 现在国家需要在某些城市对之间建立一些贸易路线, 使得整个国家的任意两个城市都直接或间接的连通.为了 ...

随机推荐

  1. 二手前端入门React项目

    个人对ReactJS这门技术比较感兴趣,在基友的帮助下成功创建了一个React标准前端工程,过程中遇到了不少麻烦,今天作为笔记一般记录一下遇到的问题和解决方案. 基础环境 手头一台Mac 使用OSX系 ...

  2. 回归到jquery

    最近在做一个公司的老产品的新功能,使用原来的技术框架,jquery和一堆插件,使用jquery的话,灵活性是有了,但是对于一个工作了3年多的我来说,很low,没什么成就感,技术本身比较简单,但是业务的 ...

  3. 关于在JS中AJAX导致跨域问题的解决

    在部署一个原声的前端项目的时候,请求该服务器后端接口时发现出现了CORS跨域的问题,但是服务端已经做了同源策略的兼容,常见问题,遂记录. 报错信息: XMLHttpRequest cannot loa ...

  4. window.open完美替代window.showModalDialog

    var url = "http//:www.baidu.com/" var name = "百度"; var iWidth = 1100;//弹窗宽度 var ...

  5. WampServer访问出现403forbidden的问题解决

    1,软件装上以后出现所有服务运行,80端口未被占用的情况下服务器一直处于离线状态 解决方案如下: 网络上面很多教程多说切换服务器为在线状态即可,但是我发现我的菜单里面并没有,用命令又嫌麻烦 在图表上面 ...

  6. SQL Full Join 的 Where条件

    SQL需求是损益视图串资产负债视图 用Excel透视表模拟出来的结果就是 用SQL查询如下: 当Where条件是左边的视图的时候 select 损益视图.年 ,损益视图.年月 ,损益视图.期间 ,损益 ...

  7. spark 广播变量

    Spark广播变量 使用广播变量来优化,广播变量的原理是: 在每一个Executor中保存一份全局变量,task在执行的时候需要使用和这一份变量就可以,极大的减少了Executor的内存开销. Exe ...

  8. 最近用.NET实现DHT爬虫,全.NET实现

    最近用.NET实现DHT爬虫,全.NET实现,大家可以加我QQ交流下  309159808

  9. Scala 中使用 akka system 的 scheduler 的例子

    这是在scala控制台直接执行的例子.   import akka.actor._ import scala.concurrent.duration._ import scala.concurrent ...

  10. netty用户指南

    Netty用户指南 一.前言 1.问题 当今世界我们需要使用通用的软件或库与其他组件进行通信,例如使用HTTP客户端从服务器中获取信息,或通过网络服务调用一个远程的方法.然而通用的协议及其实现通常不具 ...