HDU 1850 (number of Nim game winning schemes) Being a good boy in Spring Festival

Source: Internet
Author: User

Considering the process of proving the Bouton theorem, the Nim with n number and (XOR) is X, the highest bit of 1 in the K-bit, then the n number must have a Y in the K is also a 1.

To change the number of Y to x xor y, then the number of N Nim and 0, will be converted to the initiator will be defeated situation.

So how many kinds of the initiator, just see the number of N in how many y, to meet the binary K is a 1.

1#include <cstdio>2 3 Const intMaxh = -;4 Const intMAXN = -+Ten;5 intA[MAXN];6 7 intMain ()8 {9     intN;Ten      while(SCANF ("%d", &n) = =1&&N) One     { A         ints =0; -          for(inti =0; I < n; i++) {scanf ("%d", &a[i]); S ^=a[i];} -         if(!s) {Puts ("0");Continue; } the         inth =0; -          for(inti =0; i < maxh; i++)if(S & (1<< i)) H =i; -         intCNT =0; -          for(inti =0; I < n; i++)if(A[i] & (1<< h)) cnt++; +printf"%d\n", CNT); -     } +  A     return 0; at}
code June

HDU 1850 (number of Nim game winning schemes) Being a good boy in Spring Festival

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.