http://wikioi.com/problem/1287/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long LL;
#define maxn 1005
long long a[ maxn ][ maxn ] , b[ maxn ][ maxn ] , c[ maxn ][ maxn ] ;
int main()
{
int n1 , n2 , m1 , m2 ;
cin >> n1 >> m1 ;
memset( c , 0 , sizeof( c ) ) ;
for( int i = 1 ; i <= n1 ; ++i )
{
for( int j = 1 ; j <= m1 ; ++j )
{
cin >> a[ i ][ j ] ;
}
}
cin >> n2 >> m2 ;//cout << "aaaaaaaaaaaaaa " << endl ;
for( int i = 1 ; i <= n2 ; ++i )
{
for( int j = 1 ; j <= m2 ; ++j )
{
cin >> b[ i ][ j ] ;
}
//
}
for( int i = 1 ; i <= n1 ; ++i )
{
for( int j = 1 ; j <= m2 ; ++j )
{
for( int k = 1 ; k <= n2 ; ++k )
{
c[ i ][ j ] = c[ i ][ j ] + a[ i ][ k ] * b[ k ][ j ] ;
}
}
}
for( int i = 1 ; i <= n1 ; ++i )
{
for( int j = 1 ; j <= m2 ; ++j )
{
if( j != m2 )
cout << c[ i ][ j ] << " " ;
else
cout << c[ i ][ j ] ;
}
cout << endl ;
}
return 0 ;
}