SRM 621 D2L3: MixingColors, math

Source: Internet
Author: User

 

 

Calculate the basis of the linear space by using Gaussian deyuan, that is, the rank of the matrix.

Code:

 

#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 ************************/
                        
                       
                      
                     
                    
                   
                  
                 
                
               
             
            
           
          
         
        
       
      
     
    
   
  
 


 

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.