zoukankan      html  css  js  c++  java
  • BZOJ3105 新Nim游戏 【拟阵】

    题目分析:

    我不知道啥是拟阵啊,但有大佬说线性基相关的都是拟阵,所以直接贪心做了。

    题目代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 const int maxn = 120;
     5 
     6 int n;
     7 int a[maxn];
     8 int bas[maxn];
     9 
    10 void read(){
    11     scanf("%d",&n);
    12     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    13     sort(a+1,a+n+1);
    14 }
    15 
    16 void work(){
    17     long long ans = 0;
    18     for(int i=n;i>=1;i--){
    19         int dt = a[i];
    20         for(int j=30;j>=0;j--){
    21             if(!(a[i] & (1<<j)))continue; 
    22             if(bas[j] == 0){bas[j] = a[i];break;}
    23             else a[i] ^= bas[j];
    24         }
    25         if(a[i] == 0) ans += dt;
    26     }
    27     printf("%lld
    ",ans);
    28 }
    29 
    30 int main(){
    31     read();
    32     work();
    33     return 0;
    34 } 
  • 相关阅读:
    webform传值
    webform控件以及使用
    SQL Server 基本数据类型
    数据库设计三大范式
    第一阶段考试
    弹出层
    三级联动日期选择
    DOM例题
    JS方法
    DOM
  • 原文地址:https://www.cnblogs.com/Menhera/p/9748247.html
Copyright © 2011-2022 走看看