题目链接:http://poj.org/problem?id=2478 Farey Sequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19736 Accepted: 7962 Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with…
题目链接:https://vjudge.net/problem/POJ-2407 题意:给出n,求0..n-1中与n互质的数的个数. 思路:欧拉函数板子题,先根据唯一分解定理求出n的所有质因数p1,p2,...,pn,然后根据Φ(m)=m*∏(1-1/pi)计算即可. AC代码: #include<cstdio> using namespace std; int n,ans; int main(){ while(scanf("%d",&n),n){ ans=n; ;…
http://acm.nyist.net/JudgeOnline/problem.php?pid=42题目链接 #include <cstdio> #include <cstring> #define CLR(arr) memset(arr,0,sizeof(arr)) #define P 1001 int G[P],fa[P]; int find(int x){return x==fa[x]?x:x=find(fa[x]);} int main() { int n,a,b…
题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=1070 题目类型: 欧拉道路 题目: Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve…
In a country, there are a number of cities. Each pair of city is connected by a highway, bi-directional of course. A road-inspector’s task is to travel through the highways (in either direction) and to check if everything is in order. Now, a road-ins…