[POJ2478]Farey Sequence (欧拉函数)

发布于 2018-01-11  226 次阅读


本文章由SYCstudio或本站其它作者所有,请勿擅自转载

本文链接地址:[POJ2478]Farey Sequence (欧拉函数)

Description

The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are
F2 = {1/2}
F3 = {1/3, 1/2, 2/3}
F4 = {1/4, 1/3, 1/2, 2/3, 3/4}
F5 = {1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5}

You task is to calculate the number of terms in the Farey sequence Fn.

Http

POJ

Tag

欧拉函数

题目大意

给定正整数\(N\),求小于等于\(N\)的互质的数的个数

解决思路

求小于等于\(N\)的互质的数的个数,就是求\(\sum \phi(i)\),线性筛出$$\phi(i)$$即可,但要注意虽然$$\phi(1)==1$$,但这里不能统计进去

代码

本文章由SYCstudio或本站其它作者所有,请勿擅自转载

本文链接地址:[POJ2478]Farey Sequence (欧拉函数)


HNCJ OIer