题解 | #最简真分数#
最简真分数
https://www.nowcoder.com/practice/1f1db273eeb745c6ac83e91ff14d2ec9
#include<cstdio> #include<vector> using namespace std; int GYS(int x, int y){ if (y == 0)return x; else return(GYS(y, x%y)); } int main(){ int n; vector<int>vec; while (scanf("%d", &n) != EOF){ if (0 == n){ break; } for (int i = 0; i < n; i++){ int m; scanf("%d", &m); vec.push_back(m); } int sum=0; for (int i = 0; i < n; i++){ for (int j = i; j < n; j++){ if (GYS(vec[i], vec[j]) == 1){ sum++; } } } printf("%d\n", sum); } }