【題解】Codeforces 1382B. Sequential Nim

【題目敘述】http://codeforces.com/contest/1382/problem/B

#include <iostream>
using namespace std;
 
int t, n, a[100005];
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        a[n] = 0;
        for (int i = n-1; i >= 0; i--){
            if (a[i] > 1) a[i] = 1;
            else a[i] = a[i+1]^1;
        }
        if (a[0]) cout << "First\n";
        else cout << "Second\n";
    }
}
分享本文 Share with friends