C++ 题目没说:输入0结束

#include<iostream>
#include<string>
#include<algorithm>
#define MAX 600
using namespace std;
int a[MAX + 1];
//判断是否最简真分数
bool is_ok(int i, int j) {
	if (a[i] == 1)return true;
	for (int k = 2; k <= a[i]; k++) {
		if (a[j] % k == 0&&a[i]%k==0) {
			return false;
		}
	}
	return true;
}
int main() {

	int n; 
	while (cin >> n) {
		if (n == 0)return 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		int num = 0;//组合数量
		for (int i = 0; i < n - 1; i++) {//选分子
			for (int j = i + 1; j < n; j++) {//选分母
				if (a[i] == a[j])continue;//出现相同的数字
				if (is_ok(i, j)) {
					num++;
				}
			}
		}
		cout << num << endl;
	}
	
	
	return 0;
}