hdu1850 Being a good boy in Spring Festival, Nim game (Mimm game), Min sum

Source: Internet
Author: User

Test instructions

There are m stacks of poker on the table, and the number of cards per pile is ni (i=1 ... M);

Two people take turns, each step can choose a bunch and take away any cards;
The poker on the table is all taken out, then the game is over, and the last person to pick the card is the winner.


Exercises
Nimbo Game (Nimm game)

First of all heap Nim-sum = N1 ^ N2 ^ ... NM
And then
Res =nim-sum ^ Ni
If res < NI, then the initiator player as long as the first step from the Ni heap to take ni-res, then the remaining situation nim-sum = 0,
That is, for the rest of the situation is a must-fail state. Then this is a winning scheme.
There is at most one method for each heap operation to defeat the required point (nim-sum = 0)



#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;int a[200];int main () {    int n;    while (~SCANF ("%d", &n) &&n) {        int sum = 0;        for (int i=0; i<n; ++i) {            scanf ("%d", &a[i]);            Sum ^= a[i];        }        int ans = 0;        for (int i=0; i<n; ++i)            if (A[i] > (sum^a[i])) ans++;        printf ("%d\n", ans);    }    return 0;} <span style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "White-space:normal;" ></span></span>

hdu1850 Being a good boy in Spring Festival, Nim game (Mimm game), Min sum

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.