"POJ1740" A New Stone Game Construction Games

Source: Internet
Author: User

Test instructions: Multiple sets of data, one first n for each set of data, and then the number of n heap stones.

Two people take turns operation, each can throw a K stone (K∈[1,xi]) from a certain quantity of the stone heap of Xi, then the remaining xi-k, can divide G stone randomly to other heap (cannot build out of thin air, g∈ (0,xi-k)).


Exercises

First, the equilibrium state is constructed:

There are even heaps, and can be paired 22.

This can be understood as the initiator play a bit, the other can have the same coping strategies. (The brain is just a little bit, this is not a difficult teenager)


So how to construct a balance state?

Consider if the total number is odd, then there is.


Then if the total number is even, then there are two graphs.

We'll sort the stones first, then the highest one on the left.


Figure two is the pairing method. (It's actually very water.)


But if the beginning is balanced, then no recruit, the initiator can only lose.

Well, you can only say that.

OK, you can look at the code:

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 15using Namespace Std;int stone[n],n;int Main () {//freopen ("test.in", "R", stdin), int i,j,k;while (scanf ("%d", &n), N) {for (i =1;i<=n;i++) scanf ("%d", &stone[i]), if (n&1) puts ("1"), else {sort (stone+1,stone+n+1); bool Flag=1;for (i=1; i<n;i+=2) flag&= (stone[i]==stone[i+1]), if (flag) puts ("0"); else puts ("1");}} return 0;}


"POJ1740" A New Stone Game Construction Games

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.