# 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]:

``````#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

## JavaScript syntax (function) — determine whether a number is a prime number?

Prime numbers, also known as prime numbers, are numbers that can only be divided by 1 and itself (for example, 2, 3, 5, 7, 9), ranging from 2 to n-1, and 1 is not included. The code is as follows： Idea: 1. Enter a value and carry out a for loop (the maximum range cannot […]