HDU 3032 Nim or not Nim? (SG function in game)

Source: Internet
Author: User


Q: the transformation of the classic Nim game gives you n heap stones pi, each Heap has pi stones,

Alice and Bob take turns to take stones. Each time they take any stones from any pile, they can also be divided into two small piles.

(The number of stones in each heap must not be 0). The winner wins the first one.


Idea: Find the rule after finding the SG function;


SG Function Definition and Method: Click to open the link


#include
 
  #include
  
   #include
   
    #include
    
     #include
     #include
      
       #include
       
        #include 
        
         #include 
         
          #include#include
          
           using namespace std;#define INF 1e8#define eps 1e-8#define LL long long#define maxn 1000001#define PI acos(-1.0)int sg[maxn],vis[maxn];void SG(){sg[0]=0;sg[1]=1;for(int i=2;i<100;i++){memset(vis,0,sizeof(vis));for(int j=i-1;j>=0;j--){vis[sg[j]]=1;}for(int j=1;j
           
            

Related Article

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.