A Very Easy Math Problem

推式子

∑ai=1n∑a2=1n⋯∑ax=1n(∏j=1xajk)f(gcd(a1,a2,…,ax))×gcd(a1,a2,…,ax)\sum_{a_i = 1} ^{n} \sum_{a_2 = 1} ^{n} \dots \sum_{a_x = 1} ^{n} \left(\prod_{j = 1} ^{x} a_j ^ k \right)f(gcd(a_1, a_2, \dots, a_x))\times gcd(a_1, a_2, \dots, a_x) ai​=1∑n​a2​=1∑n​⋯ax​=1∑n​(j=1∏x​ajk​)f(gcd(a1​,a2​,…,ax​))×gcd(a1​,a2​,…,ax​)

=∑d=1ndf(d)∑ai=1n∑a2=1n⋯∑ax=1n(∏j=1xajk)(gcd(a1,a2,…,ax)==d)= \sum_{d = 1} ^{n}df(d)\sum_{a_i = 1} ^{n} \sum_{a_2 = 1} ^{n} \dots \sum_{a_x = 1} ^{n} \left(\prod_{j = 1} ^{x} a_j ^ k \right)(gcd(a_1, a_2, \dots, a_x) == d) =d=1∑n​df(d)ai​=1∑n​a2​=1∑n​⋯ax​=1∑n​(j=1∏x​ajk​)(gcd(a1​,a2​,…,ax​)==d)

有∑ai=1n∑a2=1n⋯∑ax=1n(∏j=1xajk)=(∑i=1nik)x有\sum_{a_i = 1} ^{n} \sum_{a_2 = 1} ^{n} \dots \sum_{a_x = 1} ^{n} \left(\prod_{j = 1} ^{x} a_j ^ k \right) = \left(\sum_{i = 1} ^{n} i ^ k \right) ^ x 有ai​=1∑n​a2​=1∑n​⋯ax​=1∑n​(j=1∏x​ajk​)=(i=1∑n​ik)x

=∑d=1ndkd+1f(d)(∑i=1ndik)x(gcd(a1,a2,…,ax)==1)= \sum_{d = 1} ^{n}d ^ {kd + 1} f(d)\left(\sum_{i = 1} ^{\frac{n}{d}} i ^ k \right) ^ x (gcd(a_1, a_2, \dots, a_x) == 1) =d=1∑n​dkd+1f(d)⎝⎛​i=1∑dn​​ik⎠⎞​x(gcd(a1​,a2​,…,ax​)==1)

=∑d=1ndkd+1f(d)(∑i=1ndik)x∑t∣ndμ(t)= \sum_{d = 1} ^{n}d ^ {kd + 1} f(d)\left(\sum_{i = 1} ^{\frac{n}{d}} i ^ k \right) ^ x \sum_{t \mid \frac{n}{d}}\mu(t) =d=1∑n​dkd+1f(d)⎝⎛​i=1∑dn​​ik⎠⎞​xt∣dn​∑​μ(t)

=∑d=1nf(d)ddx+1∑t=1ndμ(t)tkx(∑i=1ndtik)x= \sum_{d = 1} ^{n} f(d) d ^{dx + 1} \sum_{t = 1} ^{\frac{n}{d}} \mu(t) t^{kx} \left( \sum_{i = 1} ^{\frac{n}{dt}} i ^ k\right) ^ x =d=1∑n​f(d)ddx+1t=1∑dn​​μ(t)tkx⎝⎛​i=1∑dtn​​ik⎠⎞​x
另T=dtT = dtT=dt
=∑T=1n(∑i=1nTik)xTkx∑d∣Tdμ(Td)f(d)= \sum\limits_{T = 1} ^{n}\left( \sum_{i = 1} ^{\frac{n}{T}}i ^ k \right) ^ x T ^ {kx} \sum_{d\mid T}d \mu(\frac{T}{d})f(d) =T=1∑n​⎝⎛​i=1∑Tn​​ik⎠⎞​xTkxd∣T∑​dμ(dT​)f(d)
最后我们只要先预处理出Tkx∑d∣Tdμ(Td)f(d)T ^ {kx} \sum_{d\mid T}d \mu(\frac{T}{d})f(d)Tkx∑d∣T​dμ(dT​)f(d),就能就简简单单的进行除法分块了。

代码

/*Author : lifehappy
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>#define mp make_pair
#define pb push_back
#define endl '\n'
#define mid (l + r >> 1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define ls rt << 1
#define rs rt << 1 | 1using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;inline ll read() {ll f = 1, x = 0;char c = getchar();while(c < '0' || c > '9') {if(c == '-')    f = -1;c = getchar();}while(c >= '0' && c <= '9') {x = (x << 1) + (x << 3) + (c ^ 48);c = getchar();}return f * x;
}const int N = 2e5 + 10, mod = 1e9 + 7;int mu[N];ll sum1[N], sum2[N], sum3[N], f[N], k, x;bool st[N];vector<int> prime;ll quick_pow(ll a, ll n, ll mod) {ll ans = 1;while(n) {if(n & 1) ans = ans * a % mod;a = a * a % mod;n >>= 1;}return ans;
}void mobius() {f[1] = st[0] = st[1] = mu[1] = 1;for(int i = 2; i < N; i++) {f[i] = 1;if(!st[i]) {prime.pb(i);mu[i] = -1;}for(int j = 0; j < prime.size() && i * prime[j] < N; j++) {st[i * prime[j]] = 1;if(i % prime[j] == 0) break;mu[i * prime[j]] = -mu[i];}}for(int i = 2; i * i < N; i++) {for(int j = i * i; j < N; j += i * i) {f[j] = 0;}}for(int i = 1; i < N; i++) {for(int j = i; j < N; j += i) {sum3[j] = (sum3[j] + i * mu[j / i] % mod * f[i] % mod + mod) % mod;}}for(int i = 1; i < N; i++) {ll temp = quick_pow(i, k, mod);sum1[i] = (sum1[i - 1] + temp) % mod;sum2[i] = (sum2[i - 1] + quick_pow(temp, x, mod) * sum3[i] % mod) % mod;}
}int main() {// freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);// ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int T = read();k = read(), x = read();mobius();while(T--) {ll n = read(), ans = 0;for(ll l = 1, r; l <= n; l = r + 1) {r = n / (n / l);ans = (ans + quick_pow(sum1[n / l], x, mod) * (sum2[r] - sum2[l - 1]) % mod) % mod;}cout << (ans % mod + mod) % mod << endl;}return 0;
}

HDU 6833 A Very Easy Math Problem相关推荐

  1. HDU 6833 A Very Easy Math Problem(莫比乌斯反演)

    原题题面 Given you n,x,k , find the value of the following formula: ∑ a 1 = 1 n ∑ a 2 = 1 n . . . ∑ a x ...

  2. 2020杭电多校第六场 A Very Easy Math Problem 莫比乌斯反演 (HDU 6833)

    A Very Easy Math Problem 题解 ∑ a 1 = 1 n ∑ a 2 = 1 n ⋅ ⋅ ⋅ ∑ a x = 1 n ( ∏ j = 1 x a j k ) f ( g c d ...

  3. HDU 6607 Easy Math Problem(杜教筛 + min_25 + 拉格朗日插值)

    Easy Math Problem 推式子 ∑i=1n∑j=1ngcd(i,j)Klcm(i,j)[gcd(i,j)∈prime]∑i=1n∑j=1ngcd(i,j)K−1ij[gcd(i,j)∈pr ...

  4. 【HDU - 1757】A Simple Math Problem (矩阵快速幂)

    题干: Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.  If x >= 10 f(x) = ...

  5. hdu 1757【A Simple Math Problem】

    矩阵相乘 代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 struct matrix 5 { 6 int g[10][10 ...

  6. [HDU6833]A Very Easy Math Problem

    题意 求 ∑ a 1 = 1 n ∑ a 2 = 1 n ⋯ ∑ a x = 1 n ( ∏ j = 1 x a j k ) f ( gcd ⁡ ( a 1 , a 2 , . . . , a x ) ...

  7. hdu 5435 A serious math problem(数位dp)

    题目链接:hdu 5435 A serious math problem 裸的数位dp. #include <cstdio> #include <cstring> #inclu ...

  8. HDU - 5974 A Simple Math Problem 题解

    D - Simple Math Problem 戳上方进入原题哟~ 题目大意 给一个数 a,b. 让你求满足一下条件的 X,Y: X+Y = a LCM(X,Y) = b 解析 题目给出时间限制1s, ...

  9. hdu 2058 解题报告 - The sum problem

    hdu 2058 解题报告 - The sum problem 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2058 等差求和公式: Sn=(a1+aN ...

最新文章

  1. Sql Server相关报错解决
  2. 乱乱乱!那些惨不忍睹的机房布线
  3. 专栏 | 基于 Jupyter 的特征工程手册:特征选择(一)
  4. 前端学习(1921)vue之电商管理系统电商系统之绘制基本布局并且获取数据
  5. Django初次体验
  6. ubuntu下安装Node.js(源码安装)
  7. @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 注解的作用
  8. mybatis 不同格式日期比较大小_怎样创建一个命令函数来获得不同国家和应用程序所要求的大多数日期格式...
  9. 5-5 常用系统接口
  10. 开源项目bootdo的实战开发笔记
  11. [NOIP2017 普及组] 成绩
  12. McAfee官方卸载工具下载及使用
  13. 实时数据采集架构原理(蜂巢)
  14. 论文笔记:多标签学习——ACkEL算法
  15. python并行编程 - 介绍篇
  16. H3C MSR 2600-10 Winet 交换机consol口设置
  17. 游戏私服频繁被DDOS攻击怎么办
  18. php ml 非线性回归,科学网—非线性回归(迭代法)及其两种拟合曲线:y=a+b*exp(c*x) - 梅卫平的博文...
  19. 7 月 24 号腾讯副总张小龙内部讲座《通过微信谈产品》
  20. 无人驾驶技术入门(八)| 被严重低估的传感器超声波雷达

热门文章

  1. python123输出hello world_Python基础:输入与输出
  2. 世上最“贵”的河:河里石头比黄金还值钱?甚至还有士兵驻守!
  3. π!到底蕴藏了多少不为人知的秘密?|今日最佳
  4. python3 2.00gb怎么去掉单位_最值得期待的Python 3.9的新功能
  5. 刷magisk模块后不能开机_刷Magisk模块开机卡Logo了怎么办?两种方法教你轻松解决...
  6. python时间函数报错_Python Day11-LEGB-global-时间函数
  7. tftp 服务器 ip_360Stack裸金属服务器部署实践
  8. 怎么部署_2020怎么部署新零售商城?
  9. php 输入值,php-HTML输入值更改
  10. python最大值_Python 获取最大值函数|python3教程|python入门|python教程