[hdu6428]Problem C. Calculate
题目大意:有$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的更多相关文章
- @hdu - 6428@ Problem C. Calculate
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 A, B, C,求: \[\sum_{i=1}^{A}\s ...
- Gambler's Ruin Problem and 3 Solutions
In my stochastic processes class, Prof Mike Steele assigned a homework problem to calculate the ruin ...
- HDU 1402 A * B Problem Plus(FFT)
Problem Description Calculate A * B. Input Each line will contain two integers A and B. Process to ...
- HDU 1402:A * B Problem Plus
A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 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 ...
- HD1000A + B Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s) ...
- 【HDU1402】【FNT版】A * B Problem Plus
Problem Description Calculate A * B. Input Each line will contain two integers A and B. Process to ...
- 【HDU1402】【FFT】A * B Problem Plus
Problem Description Calculate A * B. Input Each line will contain two integers A and B. Process to e ...
- 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 ...
随机推荐
- C#如何使用异步编程【BeginInvoke/EndInvoke】
怎么使用异步,就是用委托进行处理,如果委托对象在调用列表中只有一个方法,它就可以异步执行这个方法.委托类有两个方法,叫做BeginInvoke和EndInvoke,它们是用来异步执行使用. 异步有三种 ...
- 使用工具Android Studio实现一个简单的Android版的新闻APP
目的: 这是我学完Android课程后所写的一个小的.简单版的新闻APP 技术概要: 用到了SQLite数据库,用它来存储每篇新闻下的评论 新闻的来源是新浪新闻,我通过使用Fiddler来对新浪新闻A ...
- SAP标准导出功能 - 删除默认选定格式
我们经常会使用SAP系统的标准功能导出ALV显示的数据,一般会选择电子表格. 选择电子表格之后,需要选择电子表格的具体格式. 选择格式之后点击确定,会弹出保存对话框. 如果在使用这个功能的时候,选择了 ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [spring/applicationContext-service.xml]: Cannot resolve refer
<!-- aop --> <aop:config> <aop:pointcut expression="execution(* com.zsn.Service. ...
- Java执行存储过程
1.JDBC调用存储过程: CallableStatement /** *p是要调用的存储过程的名字,存储过程的4个参数,用4个?号占位符代替 *其余地方写法固定 */ CallableStateme ...
- BeanFactory和IOC控制反转
之前在看spring,看IOC实在是云里雾里,包括看AOP也是云里雾里的,后来重新学习Java Web,做了一个简单的web项目,再之后看了崔希凡老师的视频,Day27和Day28两天的内容,真的很有 ...
- iar注释快捷键
选中多行后注释快捷键:Ctrl+K 取消多行注释快捷键:Ctrl+Shift+K
- Nginx技术深入剖析
Nginx软件功能模块说明 核心功能模块(Core functionality):主要对应配置文件的Main区块和Events区块. 标准的http功能模块: 企业 场景常用的Nginx http功能 ...
- POJ:3258-River Hopscotch
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17740 Accepted: 7414 Desc ...
- 绿盟python测试实习面试
1.简历问题 低级错误:时间写错 最近好像越来越马大哈了,总是犯低级错误. 上次的开题报告首页,这次的时间,每次都有小问题,确是大毛病 到底哪里出错了 2 RHCE证书好像没有用 面试官根本就不懂这个 ...