设为首页 加入收藏

TOP

SGU 275 To xor or not to xor (高斯消元)
2015-07-20 17:22:26 来源: 作者: 【 】 浏览:4
Tags:SGU 275 xor not 高斯

题目地址:SGU 275

首先,贪心的思想,每一二进制位上要尽量是1,而能不能是1用高斯消元来解决。当该位有一个可以使之为1的变元时,就说明这位可以为1,而且令该变元控制该位,然后向低位消元。

代码如下:

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
         #include 
         
           #include 
          
            using namespace std; #define LL __int64 #define pi acos(-1.0) const int mod=1e9+7; const int INF=1e9; const double eqs=1e-9; int mat[100][110], equ, var, vis[110]; LL a[100]; LL gauss() { LL ans=0; int i, j, k, h; memset(vis,0,sizeof(vis)); for(i=equ-1;i>=0;i--){ ans<<=1; for(j=0;j
           
            =0;k--){ if(mat[k][j]){ for(h=0;h<=var;h++){ mat[k][h]^=mat[i][h]; } } } } } return ans; } int main() { int n, i, k; LL y; scanf("%d",&n); equ=0; var=n; for(i=0;i
            
             >=1; } equ=max(equ,k); } for(i=0;i
             
              

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇BZOJ 1443 JSOI 2009 游戏Game 二.. 下一篇HDU 4738 Caocao's Bridges(..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何理解c语言指针和 (2025-12-27 01:19:11)
·为什么C标准库没有链 (2025-12-27 01:19:08)
·玩转C语言和数据结构 (2025-12-27 01:19:05)
·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)