[Sdoi 2016] Coin game __ Topic Analysis

Source: Internet
Author: User
Topic Description:

Fog- Topic analysis:

The first thing we can find is that the form of each number is the same: c∗2a∗3b
If we set up a two-dimensional coordinate system, the horizontal axis represents a, and the ordinate represents B, which can be represented because of the rules of the game. Every turn of the point is C the same. So it has nothing to do with C.
So we let Sg[i][j] say I this point is different from all previous points, and the SG value of this point is how much. This can be a violent enumeration of all subsequent states when asked.
One problem is what the SG values for all the points that will be flipped in a subsequent state. Turning a point in the calculation of an answer will have an effect on the previous point.
In fact, these two are a problem, is that this point and its successor point is independent.
is actually independent. We can look for the process of SG, if we turn this point will have an impact on some of the previous points, but for a certain point is the total number of times is a certain, but the order is different, so regardless of the order is how this point state will be this, that is, this point can be seen as independent. Topic Link:

Luogu 4077
Bzoj 4600 Ac code:

#include <cstdio> #include <iostream> #include <cstring> int sg[20][20],vis[500],q,n,ans,maxq;
    void Getsg () {int o,k;
    memset (sg,0,sizeof (SG));
    int x=0,y=0,m;
    M=n;
    while (m>=2) m/=2,x++;
    M=n;
     while (m>=3) m/=3,y++;
         for (int i=0;i<=x;i++) for (int j=0;j<=y;j++) {memset (vis,0,sizeof (VIS)); for (int p=1;p<=i;p++) for (int q=1;q<=maxq&&p*q<=i;q++) {for (O=-1,K=1;K&L
            t;=q;++k) o= (o==-1) sg[i-p*k][j]:(o^sg[i-p*k][j]);
          if (o!=-1) vis[o]=true; for (int p=1;p<=j;p++) for (int q=1;q<=maxq&&p*q<=j;q++) {for (O)
            =-1,k=1;k<=q;k++) o= (o==-1) sg[i][j-p*k]:(o^sg[i][j-p*k]);
          if (o!=-1) vis[o]=1; for (o=0;;;
            ++o) if (!vis[o]) {sg[i][j]=o;
          Break
    int main () {scanf ("%d", &q);
  while (q--)  {scanf ("%d%d", &AMP;N,&AMP;MAXQ);
        GETSG ();
        int flag=0;
            for (int i=1,x,m;i<=n;i++) {scanf ("%d", &x);
            if (x) continue;
            int s1=0,s2=0;
            M=i;
            while (m%2==0) m/=2,s1++;
            while (m%3==0) m/=3,s2++;
        FLAG^=SG[S1][S2]; } puts (flag?)
    Win ":" Lose ");
return 0; }

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.