POJ 1222-extended lights out (Gaussian elimination element for solving equations)

Source: Internet
Author: User

POJ 1222-extended lights out (Gaussian elimination element for solving equations)

 

There is a matrix of 5*6. Each position indicates a button and a light. 1 indicates bright, and 0 indicates extinction. Every time you press the button at the next position, it switches all the states of the lights around it (the question shows how it affects ), ask which buttons can be pressed in such a square matrix to turn the entire square matrix out. In this case, 1 indicates that the square is pressed, and 0 indicates that the square is not pressed.

 

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include #include 
       
        #include 
        
         #include 
         
          #include
          using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const double pi= acos(-1.0);const double esp=1e-6;const int MAXN=40;int aug[MAXN][MAXN];int x[MAXN];int m,n;int dx[]= {0,0,1,0,-1};int dy[]= {0,1,0,-1,0};int Gauss() { int i,j; int row,col,max_r; int tmp; for(row=0,col=0; row
           
            abs(aug[max_r][col])) max_r=i; } if(max_r!=row) { for(j=row; j
            
             =0; i--) { x[i]=aug[i][n]; for(j=i+1; j
             
              =0&&x<5&&y>=0&&y<6) { aug[i*6+j][x*6+y]=1; } } Gauss(); printf(PUZZLE #%d,icase++); for(i=0; i<30; i++) { if(i%6!=0) printf( %d,x[i]); else printf(%d,x[i]); } puts(); } return 0;}
             
            
           
         
        
       
      
     
    
   
  
 


 

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.