题解 | #最简真分数#
最简真分数
http://www.nowcoder.com/practice/1f1db273eeb745c6ac83e91ff14d2ec9
#include<iostream> #include<cstdio> using namespace std; const int MAXN=600; int GCD(int a,int b){ if(b==0){ return a; } else{ return GCD(b,a%b); } } int main(){ int number[MAXN]; int n; while(scanf("%d",&n)!=EOF){ if(n==0){ break; } for(int i=0;i<n;++i){ scanf("%d",&number[i]); } int sum=0; for(int i=0;i<n;++i){ for(int j=i+1;j<n;++j){ if(GCD(number[i],number[j])==1)++sum; } } printf("%d\n",sum); } return 0; }