文章
47
粉丝
109
获赞
8
访问
28.4k
#include<stdio.h>
int gcd(int a, int b) {
if (b == 0) return a;
else return gcd(b, a % b);
}
int main() {
int n = 0;
while (scanf("%d", &n) != EOF) {
int s[605];
for (int i = 0; i < n; i++) {
scanf("%d", &s[i]);
}
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (gcd(s[i], s[j]) == 1)
{
cnt++;
}
}
}
printf("%d\n", cnt);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发