题目大意:有$T(1\leqslant T\leqslant 10)$组数据,每组数据给你$A,B,C(0<A,B,C\leqslant 10^7)$,求$\sum\limits_{i=1}^A\sum\limits_{j=1}^B\sum\limits_{k=1}^C\varphi((i,j^2,k^3))\bmod 2^{30}$

题解:
$$
\def \dsum{\displaystyle\sum\limits}
\begin{align*}
&\dsum_{i=1}^A\dsum_{j=1}^B\dsum_{k=1}^C\varphi((i,j^2,k^3))\\
=&\dsum_{d=1}^A\varphi(d)\dsum_{i=1}^A\dsum_{j=1}^B\dsum_{k=1}^C[(i,j^2,k^3)=d]\\
\end{align*}
$$

$$
\def \dsum{\displaystyle\sum\limits}
令f(x)=\dsum_{i=1}^A\dsum_{j=1}^B\dsum_{k=1}^C[(i,j^2,k^3)=x]\\
\begin{align*}
F(x)&=\dsum_{x|p}f(p)\\
&=\dsum_{i=1}^A\dsum_{j=1}^B\dsum_{k=1}^C[x|(i,j^2,k^3)]\\
&=\dsum_{i=1}^A[x|i]\dsum_{j=1}^B[x|j^2]\dsum_{k=1}^C[x|j^3]\\
&莫比乌斯反演得:\\
f(x)&=\dsum_{x|k}\mu(\dfrac k x)F(k)\\
&=\dsum_{i=1}^A\mu(i)F(ix)\\
ans&=\dsum_{d=1}^A\varphi(d)\dsum_{i=1}^A\mu(i)F(id)\\
&=\dsum_{T=1}^AF(T)\dsum_{d|T}\varphi(d)\mu(\dfrac T d)\\
&由狄利克雷卷积得:\\
ans&=\dsum_{T=1}^AF(T)(\mu*\varphi)(d)
\end{align*}
$$

$$
狄利克雷卷积得(\mu*\varphi)(d)为积性函数\\
\def \dsum{\displaystyle\sum\limits}
令g(x)=\dsum_{d|T}\mu(d)\varphi(\dfrac T d)\\
\begin{align*}
g(1)&=1\\
g(p)&=\mu(1)\varphi(p)+\mu(p)\varphi(1)\\
&=1\cdot(p-1)+(-1)\cdot1\\
g(p^k)&=\mu(1)\varphi(p^k)\\
&+\mu(p)\varphi(p^{k-1})\\
&\qquad\vdots\\
&+\mu(p^k)\varphi(1)\\
\because&\mu(p^k)当k\geqslant2时为0\\
\therefore g(p^k)&=\mu(1)\varphi(p^k)+\mu(p)\varphi(p^{k-1})\\
&=p^k-k^{k-1}-(p^{k-1}-p^{k-2})\\
&=p^k-2p^{k-1}+p^{k-2}\\
\therefore g(p^k)&=
\begin{cases}
1(k=0)\\
p-2(k=1)\\
(p-1)^2(k=2)\\
p\cdot g(p^{k-1})(k\geqslant2)\\
\end{cases}
\end{align*}\\
可以用线性筛来做
$$

$$
\def \dsum{\displaystyle\sum\limits}
\def \dprod{\displaystyle\prod\limits}
F(x)=\dsum_{i=1}^A[x|i]\dsum_{j=1}^B[x|j^2]\dsum_{k=1}^C[x|j^3]\\
易得\dsum_{i=1}^A[x|i]=\left\lfloor\dfrac A x\right\rfloor\\
考虑\dsum_{j=1}^B[x|j^2]:\\
对x分解质因数\\
令x=\dprod p_i^{c_i}\\
令y_2(x)=\dprod p_i^{\left\lceil\dfrac{c_i}{2}\right\rceil}\\
x|j^2\Rightarrow[y_2(x)|j]\\
\therefore \dsum_{j=1}^B[x|j^2]=\left\lfloor\dfrac{B}{y_2(x)}\right\rfloor\\
同理,令y_3(x)=\dprod p_i^{\left\lceil\dfrac{c_i}{3}\right\rceil}\\
\therefore \dsum_{k=1}^C[x|j^3]=\left\lfloor\dfrac{B}{y_3(x)}\right\rfloor\\
\therefore F(x)=\left\lfloor\dfrac A x\right\rfloor\left\lfloor\dfrac{B}{y_2(x)}\right\rfloor\left\lfloor\dfrac{B}{y_3(x)}\right\rfloor\\
y_2(x),y_3(x)都可以线性筛
$$

卡点:

C++ Code:

#include <cstdio>
#define maxn 10000010
#define mod 1073741823
int Tim, A, B, C;
int pl[maxn], ptot, g[maxn], f2[maxn], f3[maxn];
int cnt[maxn];
bool isp[maxn];
inline int sqr(int x) {return x * x;}
void sieve(int n) {
g[1] = f2[1] = f3[1] = 1;
for (int i = 2; i < n; i++) {
if (!isp[i]) {
pl[ptot++] = i;
g[i] = i - 2;
f2[i] = f3[i] = i;
cnt[i] = 1;
}
for (int j = 0; j < ptot && pl[j] * i < n; j++) {
int t = pl[j] * i;
isp[t] = true;
if (i % pl[j] == 0) {
cnt[t] = cnt[i] + 1;
int p = i / pl[j];
if (p % pl[j]) g[t] = g[p] * sqr(pl[j] - 1);
else g[t] = g[i] * pl[j];
f2[t] = f2[i] * (cnt[t] & 1 ? pl[j] : 1);
f3[t] = f3[i] * (cnt[t] % 3 == 1 ? pl[j] : 1);
break;
}
cnt[t] = 1;
g[t] = g[i] * g[pl[j]];
f2[t] = f2[i] * f2[pl[j]];
f3[t] = f3[i] * f3[pl[j]];
}
}
}
int main() {
sieve(maxn);
scanf("%d", &Tim);
while (Tim --> 0) {
scanf("%d%d%d", &A, &B, &C);
int ans = 0;
for (int i = 1; i <= A; i++) ans += g[i] * (A / i) * (B / f2[i]) * (C / f3[i]);
printf("%d\n", ans & mod);
}
return 0;
}

  

[hdu6428]Problem C. Calculate的更多相关文章

  1. @hdu - 6428@ Problem C. Calculate

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 A, B, C,求: \[\sum_{i=1}^{A}\s ...

  2. Gambler's Ruin Problem and 3 Solutions

    In my stochastic processes class, Prof Mike Steele assigned a homework problem to calculate the ruin ...

  3. HDU 1402 A * B Problem Plus(FFT)

    Problem Description Calculate A * B.   Input Each line will contain two integers A and B. Process to ...

  4. HDU 1402:A * B Problem Plus

    A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  5. hdu----(1402)A * B Problem Plus(FFT模板)

    A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. HD1000A + B Problem

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s) ...

  7. 【HDU1402】【FNT版】A * B Problem Plus

    Problem Description Calculate A * B.   Input Each line will contain two integers A and B. Process to ...

  8. 【HDU1402】【FFT】A * B Problem Plus

    Problem Description Calculate A * B. Input Each line will contain two integers A and B. Process to e ...

  9. HDOJ 2114 Calculate S(n)(找周期)

    Problem Description Calculate S(n). S(n)=1^3+2^3 +3^3 +--+n^3 . Input Each line will contain one int ...

随机推荐

  1. 在线代码编辑器 Codemirror 的轻量级 React 组件

    代码编辑器 CodeMirror 的轻量级 React 组件 demo @uiw-react.github.io/react-codemirror/ 特性:

  2. c++标准之IO库

    1.面向对象的标准库 2.多种IO标准库工具 istream,提供输入操作 ostream,提供输出操作 cin:读入标准输入的istream对象.全局对象extern std::istream ci ...

  3. 基于Ceph分布式集群实现docker跨主机共享数据卷

    上篇文章介绍了如何使用docker部署Ceph分布式存储集群,本篇在此基础之上,介绍如何基于Ceph分布式存储集群实现docker跨主机共享数据卷. 1.环境准备 在原来的环境基础之上,新增一台cen ...

  4. linux学习笔记二:三种网络配置

    本文引用自:https://www.linuxidc.com/Linux/2017-05/144370.htm [linux公社] VMware为我们提供了三种网络工作模式,它们分别是:Bridged ...

  5. 申请qq第三方登录 http://www.php20.com/forum.php?mod=viewthread&tid=29 (出处: 码农之家)

    百度  qq互联  进入网站 按图中的步骤申请第三方登录即可 先申请成为开发者 审核通过后再继续操作 提交 后列表中会出现提交的申请. 状态为审核中,审核通过会得到下图. 点查看 红线后面就是appi ...

  6. redis安装与简单使用

    第一步 新建一个文件 第二步 利用winscrp软件从本机上传redis的压缩包到linux新建的rdtar目录 第三步   cd rdtar 第四步   解压  tar zxvf redis-2+t ...

  7. 【linux】【指令】systemctl 指令部分解读

    systemctl [OPTIONS...] {COMMAND} ... Query or send control commands to the systemd manager. -h --hel ...

  8. linux下,把屏幕竖起来

    xrandr -o left 向左旋转90度 xrandr -o right 向右旋转90度 xrandr -o inverted 上下翻转 xrandr -o normal 回到正常角度

  9. win10鼠标右键菜单在左边,怎么改回右边

    键盘上按WIN+R打开运行窗口,输入shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}按回车键

  10. 用python实现【五猴分桃】问题

    转载链接:https://blog.csdn.net/cy309173854/article/details/78296839 据说“五猴分桃”问题最先是由大物理学家狄拉克提出来的,这一貌似简单的问题 ...