HBC17247Diff-prime Pairs题解

水水月牙 算法基础篇 40 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
Eddy has solved lots of problem involving calculating the number of coprime pairs within some range. This problem can be solved with inclusion-exclusion method. Eddy has implemented it lots of times. Someday, when he encounters another coprime pairs problem, he comes up with diff-prime pairs problem. diff-prime pairs problem is that given N, you need to find the number of pairs , where igcd(i,j)frac{i}{gcd}gcd(i,j)i and jgcd(i,j)frac{j}{gcd(i,j)}gcd(i,j)j are both prime and i ,j ≤ N. gcd is the greatest common divisor of i and j. Prime is an integer greater than 1 and has only 2 positive divisors. Eddy tried to solve it with inclusion-exclusion method but failed. Please help Eddy to solve this problem. Note that pair and pair are considered different if i1 ≠ i2 or j1 ≠ j2.

Eddy has solved lots of problem involving calculating the number of coprime pairs within some range. This problem can be solved with inclusion-exclusion method. Eddy has implemented it lots of times. Someday, when he encounters another coprime pairs problem, he comes up with diff-prime pairs problem. diff-prime pairs problem is that given N, you need to find the number of pairs (i, j), where igcd(i,j)frac{i}{gcd(i, j)}gcd(i,j)i​ and jgcd(i,j)frac{j}{gcd(i,j)}gcd(i,j)j​ are both prime and i ,j ≤ N. gcd(i, j) is the greatest common divisor of i and j. Prime is an integer greater than 1 and has only 2 positive divisors. Eddy tried to solve it with inclusion-exclusion method but failed. Please help Eddy to solve this problem. Note that pair (i1, j1) and pair (i2, j2) are considered different if i1 ≠ i2 or j1 ≠ j2.

HBC17247Diff-prime Pairs题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC17247Diff-prime Pairs题解