HDU4920 inappropriate violence

Source: Internet
Author: User

HDU4920 inappropriate violence

Original question http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 4920

Matrix multiplication

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission (s): 848 Accepted Submission (s): 339


Problem DescriptionGiven two matrices A and B of size n × n, find the product of them.

Bobo hates big integers. So you are only asked to find the result modulo 3.


InputThe input consists of several tests. For each tests:

The first line contains n (1 ≤ n ≤800 ). each of the following n lines contain n integers -- the description of the matrix. the j-th integer in the I-th line equals Aij. the next n lines describe the matrix B in similar format (0 ≤aij, Bij ≤109 ).


OutputFor each tests:

Print n lines. Each of them contain n integers -- the matrix A × B in similar format.


Sample Input
10120 12 34 56 7


Sample Output
00 12 1


AuthorXiaoxu Guo (ftiasch)


Source2014 Multi-University Training Contest 5


RecommendWe have carefully selected several similar problems for you: 4919 4918 4917 4916 4915
// At the beginning, I thought what advanced algorithms were used for this question. Later, I found that many people have passed the process. It is probably a little tricky. // first of all. Multiplication takes more time than addition. So we can avoid multiplication and try to optimize it. // After this question, it is found that C ++ runs faster than G ++, and the same code is nearly 0.4 seconds behind it. During the competition, it was due to the fact that I had handed in G ++ T for many times. // finally, I said, cool, although the violence was not omnipotent. However, violence without tips is absolutely unacceptable. # Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     
      
# Include
      
        # Include
       
         # Include
        
          # Include
         
           # Include
          
            # Include
           
             # Include
            
              # Include
             # Include
              
                Using namespace std; # define Max 800 + 5int a [Max] [Max]; int B [Max] [Max]; int c [Max] [Max]; int main () {int n, I, j; while (~ Scanf ("% d", & n) {memset (a, 0, sizeof (a); memset (B, 0, sizeof (B); memset (c, 0, sizeof (c); for (I = 0; I
               
                


Related Keywords:

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.