hdu 4746Mophues[莫比乌斯反演]
1|0 Mophues
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 327670/327670 K (Java/Others)
Total Submission(s): 1669 Accepted Submission(s): 675
Problem Description
As we know, any positive integer C ( C >= 2 ) can be written as the multiply of
some prime numbers:
C = p1×p2× p3× ... × pk
which p1, p2 ... pk are all prime numbers.For example, if C = 24, then:
24 = 2 × 2 × 2 × 3
here, p1 = p2 = p3 = 2, p4 = 3, k = 4
Given two integers P and C. if k<=P( k is the number of C's prime factors), we
call C a lucky number of P.
Now, XXX needs to count the number of pairs (a, b), which 1<=a<=n , 1<=b<=m, and
gcd(a,b) is a lucky number of a given P ( "gcd" means "greatest common
divisor").
Please note that we define 1 as lucky number of any non-negative integers
because 1 has no prime factor.
Input
The first line of input is an integer Q meaning that there are Q test cases.
Then Q lines follow, each line is a test case and each test case contains three
non-negative numbers: n, m and P (n, m, P <= 5×105.
Q <=5000).
Output
For each test case, print the number of pairs (a, b), which 1<=a<=n , 1<=b<=m, and gcd(a,b) is a lucky number of P.
Sample Input
2
10 10 0
10 10 1
Sample Output
63
93
Source
2013 ACM/ICPC Asia Regional Hangzhou Online
Recommend
liuyiding | We have carefully selected several similar problems for you: 6022 6021 6020 6019 6018
//Source:http://acm.hdu.edu.cn/showproblem.php?pid=4746
Description(题意):
任何整数C
( C >= 2 )都可以写成素数之积
C = p1×p2×
p3×
... × pk
其中, p1, p2 ... pk 是素数。如
C = 24, 则
24 = 2 ×
2 × 2
× 3,
其中, p1 = p2 = p3 = 2, p4 = 3, k = 4.
给定两整数 P和 C,
若 k<=P ( k是
C的素因子个数),称
C是P的幸运数.
现小X需计算的点对 (a,
b)的个数,其中1<=a<=n
, 1<=b<=m, gcd(a,b)是 P的幸运数
( “gcd”是最大公因数).
注意:因为1无素因子,定义1为任何非负数的幸运数.
Input
首行有一个整数 T,表示有 T 组测试数据.接下来有T行,每行是一种测试数据,含3个非负整数n, m 与P (n, m, P <= 5×105. T <=5000).
Output
对每种测试数据,输出对 (a, b)的个数,其中 1<=a<=n , 1<=b<=m, 且 gcd(a,b) 是 P的幸运数.
Sample Input
2
10 10 0
10 10 1
Sample Output
63
93
__EOF__

本文链接:https://www.cnblogs.com/shenben/p/6748126.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术