"POJ2960" S-nim SG function Game Bare topic template problem

Source: Internet
Author: User

Reprint Please specify source: http://blog.csdn.net/vmurder/article/details/42653601
In fact, I just feel that the original traffic is a bit more uncomfortable than unauthorized piracy 233 ...

Test instructions

The two took turns to fetch k stones from some heap of stones,

K∈ set S, that is, the number of each fetch is limited to a number of the meaning!


Then, as with normal Nim , no one can operate and lose.

Exercises

The SG function naked question.

SG function:

The first step is to have a direction-free graph (topology map)

The boundary state is determined first, the SG value is 0, and then the violent topology draws the SG value of the other points.

The SG value is the minimum natural number that does not appear in the SG value for all subsets.


Sg==0 is negative.

The SG function satisfies all games (the starting state) of the SG xor up to 0 minus, or 1 wins.

If you are the same as me Konjac Konjac, do not want to prove that it is right, write on the line, otherwise it is over and over again decadent give up wasting time.


Code (look at a similar strip Code also line):

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 105# Define M 10100using namespace Std;int s,s[n];int sg[m];int sg (int x) {int i;if (sg[x]+1) return Sg[x];bool vis[m<<1]={ 0};for (i=1;i<=s;i++) if (s[i]<=x) VIS[SG (X-s[i])]=true;for (i=0;vis[i];i++); return sg[x]=i;} int N,m;int Main () {//freopen ("test.in", "R", stdin); int I,k,g;while (scanf ("%d", &s), S)//Data group A{for (i=1;i<=s;i+ +) scanf ("%d", &s[i]); Sort (s+1,s+s+1);//s: Aggregates memset (sg,-1,sizeof (SG)), Sg[0]=0;for (scanf ("%d", &g), g--;)//Data group B{for (k=0 , scanf ("%d", &n), n--;)//n heap of Stones {scanf ("%d", &m);//The number of stones in the heap k^=sg (m);} if (k) Putchar (' W '); else Putchar (' L ');} Puts ("");} return 0;}


"POJ2960" S-nim SG function Game template problem with naked title

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.