题解 | #最简真分数#
最简真分数
https://www.nowcoder.com/practice/1f1db273eeb745c6ac83e91ff14d2ec9
#include <bits/stdc++.h> using namespace std; int check(int a,int b){ if(b == 0) return a; else return check(b , a % b); } int main(){ int n; while(cin >> n){ if(n == 0) continue; int arr[n]; for(int i = 0 ; i < n ; i++) cin >> arr[i]; int count = 0; for(int i = 0 ; i < n - 1; i++){ for(int j = i + 1; j <= n - 1;j++){ if(check(arr[i], arr[j]) == 1) count ++; } } cout << count << endl; } }