Game theory Nim Game 2 (hh2048 question sheet)

Time:2022-5-2

[main idea of the title]:

Simple nim# output the number of schemes in the first step

[idea]:

The NIM part is an ordinary NIM. The difficulty is to output the number of schemes in the first step.

Suppose x is the value after XOR. x = a1 ^a2 ^ a3 ^ a4 ^ a5 。

The idea of the first step is to make the remaining number XOR after x = 0.

If AI > (AI ^ x) / / bit operation has the lowest priority, so it should be enclosed

Then Ai – (AI ^ x) < AI

Then there is Ai – (AI – (AI ^ x)) = = AI ^ X;

It is equivalent to the original A1 ^ A2 ^ A3 ^ A4 ^ A5 ^^ an = x;

Then subtract A1 ^ A2 ^ A3 ^ A4 ^^ (ai – (ai-(ai^x) ) ^… an  = a1^a2^a3^a4^…^ ai^x^…^ an = x^x = 0;

So just find AI > (AI ^ x).

[problem solving]:

Game theory Nim Game 2 (hh2048 question sheet)Game theory Nim Game 2 (hh2048 question sheet)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#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
#define pll pair
#define vi  vector
#define vpi vector
#define vpl vector
#define mi  map
#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<>a[i];
        res ^= a[i]  ;
    }
//    cout< (a[i]^res) ){
                ans ++ ;
//                int z = a[i] ^ res ;
//                test3(a[i],res,z);
            }
        }
        cout<>n;
        if ( n==0 ) return 0;
        solve();
    }
}

View Code