I - Game HDU - 3389

 

 

 

 

【题意】:

  有n个格子 , 每个格子有 a[i] 个旗子  。 

  每次操作:选择一个格子(下标为A) , 可以将a【A】中的任意数量的旗子放到 a【B】中。

  B的选择 :  1. B < A  2.   (B+A) % 2 = 1 && (B+A)%3 =0.

【思路】:

  阶梯尼姆。学习一下哈   

       (60条消息) 博弈论入门讲解__lanChe的博客-CSDN博客

  (60条消息) 阶梯博弈(尼姆博奕进阶)_Umikaze_的博客-CSDN博客  

   (60条消息) Game HDU - 3389 阶梯博弈,找出规律即可__lanChe的博客-CSDN博客

  重点 :

    选择终止点 ( 保证所有点 最终都会进入这个终止点   即不能转移到其他状态,其他每个状态皆可转移  )

    看到任意终止点的最小步数 是 奇还是偶进行分类  直接对奇数情况进行nim就行。

【代码】:

  

#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>

#define ms(a, b) memset(a,b,sizeof(a))
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define rep(i, a, b)  for(ll i=a;i<=b;i++)
#define lep(i, a, b)  for(ll i=a;i>=b;i--)
#define endl '\n'
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi  vector<ll>
#define vpi vector<pii>
#define vpl vector<pll>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define ff first
#define ss second
#define test4(x, y, z, a) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<"        a is "<<a<<endl;
#define test3(x, y, z) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<endl;
#define test2(x, y) cout<<"x is "<<x<<"        y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
using namespace std;
const int N = 1e5 + 10;
const int maxx = 0x3f3f3f;
const int mod = 1e9 + 7;
const int minn = -0x3f3f3f;
const int M = 2 * N;
ll T, n, m , t ;
ll a[N] ;
void solve() {
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }
    int res = 0 ;
    rep(i,1,n){
        if ( i%6 != 1 && i%6!=4 && i%6 != 3 ){
            res ^= a[i];
        }
    }
    if ( res )      cout<<"Case "<<t<<": "<<"Alice"<<endl;
    else cout<<"Case "<<t<<": "<<"Bob"<<endl;
}

int main() {
    fast;
    cin >> T;
    while (T--) {
        t++;
        solve();
    }
    return 0;
}
View Code

 

posted @ 2022-04-10 22:12  Pan_c  阅读(35)  评论(0)    收藏  举报