POJ-2478-Farey Sequence(欧拉函数)
链接: https://vjudge.net/problem/POJ-2478 题意: 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. 思路: 法雷级数的数的个数就是欧拉函数,欧拉函数打表前缀和即可。 代码: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<math.h> #include<vector> using namespace std;