uva11827 处理下输入

it2022-05-05  129

/*0.012s*/ #include<cstdio> #include<algorithm> using namespace std; int num[100], n; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int cal() { int i, j, maxn = 0; for (i = 0; i < n - 1; ++i) for (j = i + 1; j < n; ++j) maxn = max(maxn, gcd(num[i], num[j])); return maxn; } int main() { int t; char ch; scanf("%d\n", &t); while (t--) { n = 0; while (true) { scanf("%d", &num[n++]); while ((ch = getchar()) == ' ') ; // ungetc(ch, stdin); if (ch == 10 || ch == -1) break; } printf("%d\n", cal()); } return 0; }

 

转载于:https://www.cnblogs.com/zsben991126/p/10447031.html


最新回复(0)