zoukankan      html  css  js  c++  java
  • 51Nod 1714 1位数SG异或打表

    SG[i]表示一个数二进制下有i个1的SG值

    SG[0]=0

    打表:

    #include<bits/stdc++.h>
    using namespace std;
    int sg[100];
    int vis[30000000];
    int maxnnow = 0, x;
    int main() {
            sg[0] = 0;
            for (int i = 1; i <= 64; i++) {
                    for (int j = 0; j <= maxnnow; j++) {
                            vis[j] = 0;
                    }
                    maxnnow = 0;
                    for (int j1 = 0; j1 < i; j1++)
                            for (int j2 = j1; j2 < i; j2++)
                                    for (int j3 = j2; j3 < i; j3++)
                                            for (int j4 = j3; j4 < i; j4++)
                                                    for (int j5 = j4; j5 < i; j5++)
                                                            for (int j6 = j5; j6 < i; j6++)
                                                                    for (int j7 = j6; j7 < i; j7++) {
                                                                            x = sg[j1] ^ sg[j2] ^ sg[j3] ^ sg[j4] ^ sg[j5] ^ sg[j6] ^ sg[j7];
                                                                            maxnnow = max(maxnnow, x);
                                                                            vis[x] = 1;
                                                                    }
                    for (int j = 0; j <= maxnnow + 1; j++) {
                            if (vis[j] == 0) {
                                    sg[i] = j;
                                    break;
                            }
                    }
            }
            for(int i=1;i<=64;i++)
            cout<<sg[i]<<endl;
    }

    表打出来后面就很简单了

  • 相关阅读:
    CSS介绍
    docker入门
    nginx+uWSGI+django+virtualenv+supervisor发布web服务器
    niginx入门
    常用服务安装部署
    VIM
    linux基本命令
    linux目录分级
    OpenStack共享组件
    kvm认识和安装
  • 原文地址:https://www.cnblogs.com/Aragaki/p/10640722.html
Copyright © 2011-2022 走看看