显然, 如果存在两个奇数的话,就一定出现不了回文
然后,如果只有一个或者没有的话,动手画画,就会发现,是gcd了叭,真心不知道咋讲(
#include <set> #include <map> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 2e5 + 10; int x[N]; int main() { int n; cin >> n; int sum = 0; for(int i = 1; i <= n; i++) { cin >> x[i]; sum += x[i]; } if(n != 1) { int ji = 0; int flag = true; for(int i = 1; i <= n; i++) { if(x[i] % 2 == 1) ji++; } int s = x[1]; for(int i = 2; i <= n; i++) { s = __gcd(s,x[i]); } if(ji >= 2) { cout << 0 << endl; } else { cout << s << endl; } } else { cout << x[1] << endl; } return 0; }