设为首页 加入收藏

TOP

SRM 621 D2L3: MixingColors, math
2015-07-24 05:56:45 来源: 作者: 【 】 浏览:8
Tags:SRM 621 D2L3: MixingColors math

?

?

利用高斯消元求线性空间的基,也就是求矩阵的秩。

代码:

?

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include 
               
                 #include
                 #include 
                 
                   #include 
                  
                    #include 
                   
                     #include 
                    
                      #include 
                     
                       #include 
                      
                        #include 
                       
                         using namespace std; #define CHECKTIME() printf(%.2lf , (double)clock() / CLOCKS_PER_SEC) typedef pair
                        
                          pii; typedef long long llong; typedef pair
                         
                           pll; #define mkp make_pair #define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); ++it) /*************** Program Begin **********************/ class MixingColors { public: int minColors(vector 
                          
                            colors) { int res = 0; int n = colors.size(); bool used[55]; memset(used, 0, sizeof(used)); for (int i = 31; i >= 0; i--) { int pivot = 0; for (int j = 0; j < n; j++) { if (used[j]) { continue; } if ((colors[j] >> i) & 0x1) { if (!pivot) { pivot = colors[j]; used[j] = true; ++res; } else { colors[j] ^= pivot; } } } } return res; } }; /************** Program End ************************/ 
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
               
              
             
            
           
          
         
        
       
      
     
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇编程算法 - 数组构造二叉树并打印 下一篇poj 3249 Test for Job (DAG最长..

评论

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