【題解】Codeforces 1392A. Omkar and Password

【題目敘述】http://codeforces.com/contest/1392/problem/A

#include <iostream>
using namespace std;
 
int t, n, a, b;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        cin >> a;
        bool flag = false;
        for (int i = 1; i < n; i++){
            cin >> b;
            if (a != b) flag = true;
        }
        if (flag) cout << 1 << "\n";
        else cout << n << "\n";
    }
}
分享本文 Share with friends