9 条题解

  • 3
    @ 2021-10-4 16:57:07

    比如:

    (此图来自网络)

    代码如下:

    #include<cstdio>
    #define ll long long
    
    using namespace std;
    ll a[505][505],b[505][505];
    const ll mod=1000000007;
    ll n,m,p;
    
    inline ll read(){
    	ll a=0,k=1;
    	char c=getchar();
    	while (!('0'<=c&&c<='9')){
    		if (c=='-'){
    			k*=-1;
    		}
    		c=getchar();
    	}
    	while ('0'<=c&&c<='9'){
    		a=a*10+c-'0';
    		c=getchar();
    	}
    	return a*k;
    }
    
    int main(){
    	n=read(),p=read(),m=read();
    	for (ll i=1;i<=n;i++){
    		for (ll j=1;j<=p;j++){
    			a[i][j]=read();
    		}
    	}
    	for (ll i=1;i<=p;i++){
    		for (ll j=1;j<=m;j++){
    			b[i][j]=read();
    		}
    	}
    	for (ll i=1;i<=n;i++){
    		for (ll j=1;j<=m;j++){
    			ll tmp=0;
    			for (ll k=1;k<=p;k++){
    				tmp=(tmp+(a[i][k]*b[k][j]+mod)%mod+mod)%mod;
    			}
    			printf("%lld ",tmp);
    		}
    		putchar('\n');
    	}
    	return 0;
    }
    • @ 2024-7-23 21:40:16

      还是喜欢#include<bits/stdc++.h>

信息

ID
60
时间
2000ms
内存
256MiB
难度
3
标签
递交数
802
已通过
202
上传者