Transmission Door
B-June's game
WWWWODDDD (propositional person)
Base time limit: 1 seconds space limit: 131072 KB Score: 40
b June and L are going to play a game. At first there are n positive integer ai.
The two sides operate in turn. For each operation, select a positive integer x, remove it, and add 7 digit x1,x2...x7. Requirements for Xi, meet 0<= XI < x and x&xi=xi
Note 0 cannot be selected, so this game is bound to end, and whoever fails to do so will fail.
b June according to his own experience, think that the winning win a little higher, so B-June is the initiator.
B-June wants to know if he will win.
Input
First line an integer n (1 <= n <= 100000)
The following n rows n number of AI (0 <= a_i < 2^64)
Output
If the initiator wins, output "B", otherwise output "L".
Input example
4
1
2
3
4
Output example
B
Problem solving ideas (official solution):
This is a simple SG game problem.
Note that the SG value of each number is only related to how many of these are 1.
So we write a less violent violence. Can get.
A[] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 255, 256, 512, 1024, 2048, 3855, 4096, 8192, 13107, 16384, 21845, 27306, 32768, 385 06, 65536, 71576, 92115, 101470, 131072, 138406, 172589, 240014, 262144, 272069, 380556, 524288, 536169, 679601, 847140, 1 048576, 1072054, 1258879, 1397519, 2005450, 2097152, 2121415, 2496892, 2738813, 3993667, 4194304, 4241896, 4617503, 582170 4, 7559873, 8388608, 8439273, 8861366, 11119275, 11973252, 13280789, 16777216, 16844349, 17102035, 19984054, 21979742, 237 34709}
A[i] is a SG value with a number x containing I 1.
Then, all SG values can be directly different or up.
My Code:
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>using namespace STD;typedef unsigned Long LongULL;Const intMAXN =1e5+5; ULL A[MAXN];intSg[] = {0,1,2,4,8, -, +, -, -,255, the, +,1024x768,2048,3855,4096,8192,13107,16384,21845,27306,32768,38506,65536,71576,92115,101470,131072,138406,172589,240014,262144,272069,380556,524288,536169,679601,847140,1048576,1072054,1258879,1397519,2005450,2097152,2121415,2496892,2738813,3993667,4194304,4241896,4617503,5821704,7559873,8388608,8439273,8861366,11119275,11973252,13280789,16777216,16844349,17102035,19984054,21979742,23734709};intMain () {intN while(Cin>>n) {intAns =0; ULL x; for(intI=0; i<n; i++) {Cin>>x;intsum =0; while(x) {if(X &1) sum++; x>>=1; } ans ^= sg[sum]; }if(!ans)puts("L");Else puts("B"); }return 0;}
51NOD Algorithm Marathon 15 (Brexit session) B-June's Game (game)