题目大意:有$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. iOS程序猿如何快速掌握 PHP,化身"全栈攻城狮"?

    这是一篇以 iOS 开发人员的视角写给广大iOS 程序猿的 PHP 入门指南.在这篇文章里我努力去发掘 objectiv-c 与 php 之间的共性,来帮助有一定 iOS 开发经验的攻城狮来快速上手一 ...

  2. Webpack4 学习笔记四 暴露全局变量、externals

    前言 此内容是个人学习笔记,以便日后翻阅.非教程,如有错误还请指出 webpack 暴露全局变量 通过 expose-loader 内联配置 在 webpack中配置 每个模块通过注入的方式 通过CD ...

  3. JS底层挖掘

    //Promise版本的Ajaxconst getJSON = function(url) { const promise =new Promise(function(resolve, reject) ...

  4. 【赛时总结】 ◇赛时·II◇ AtCoder ABC-100

    ◆赛时·II◆ ABC-100 ■唠叨■ ABC终于超过百场比赛啦(毫不犹豫地参加).然后莫名其妙的好像是人很多,评测慢得不可理喻.然后我就--交了一大发--错误程序--然后B题就没了.最后的D题居然 ...

  5. lintcode_115_不同的路径 II

    不同的路径 II   描述 笔记 数据 评测 "不同的路径" 的跟进问题: 现在考虑网格中有障碍物,那样将会有多少条不同的路径? 网格中的障碍和空位置分别用 1 和 0 来表示. ...

  6. Java OOP——第五章 异常

    1. 尝试通过if-else来解决异常问题: Eg: public class Test2 {       public static void main(String[] args) {       ...

  7. vue笔记v-if

    如果ite.type=='培训',显示第一个img, 如果ite.type=='会议',显示第二个img

  8. 基本数据类型补充,set集合,深浅拷贝等

    1.join:将字符串,列表,用指定的字符连接,也可以用空去连接,这样就可以把列表变成str ll = ["wang","jian","wei&quo ...

  9. mysql的一些相关的命令(2013-05-05-bd 写的日志迁移

    cmd中连接:mysql -u用户名 -p用户密码 (注:u与root可以不用加空格,其它也一样)断开:exit (回车) --建立数据库creata database 数据库名;--切换到数据库下工 ...

  10. CentOS7 配置环境

    1.安装CentOS 配置环境 (1)虚拟机中安装CentOS,进入系统使用yum命令不止正常执行…… 原因: 需要设置网卡激活 解决方法: vi /etc/sysconfig/network-scr ...