【題解】CSES 1099 Stair Game

【題目敘述】https://cses.fi/problemset/task/1099/

#include <iostream>
using namespace std;
 
int t, n, a, ans;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        ans = 0;
        for (int i = 0; i < n; i++){
            cin >> a;
            if (i % 2) ans ^= a;
        }
        if (ans) cout << "first\n";
        else cout << "second\n";
    }
}
分享本文 Share with friends