This commit is contained in:
Zengtudor 2024-11-21 14:00:30 +08:00
parent c2e6538698
commit 20dae47adf
2 changed files with 85 additions and 0 deletions

30
src/B2104/B2104.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll maxn{105};
ll n,m;
ll a[maxn][maxn];
int main(){
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
const auto ra = [&](){
ll t;
for(ll i{1};i<=n;i++){
for(ll j{1};j<=m;j++){
cin>>t;
a[i][j]+=t;
}
}
};
ra();
ra();
for(ll i{1};i<=n;i++){
for(ll j{1};j<=m;j++){
cout<<a[i][j]<<' ';
}
cout<<'\n';
}
}

55
src/B2105/B2105.cpp Normal file
View File

@ -0,0 +1,55 @@
#include <bits/stdc++.h>
using ll = int64_t;
using namespace std;
const ll maxn{ll(100+5)};
ll n,m,k,a[maxn][maxn],b[maxn][maxn],c[maxn][maxn];
struct CinN{
char c;
ll n,w;
CinN &operator>>(ll &num)noexcept{
c=n=0;
w=1;
while(!isdigit(c)){
if(c=='-')w=-1;
c=getchar();
}
while(isdigit(c)){
n=n*10+c-'0';
c=getchar();
}
num=n*w;
return *this;
}
}cinn;
#define cin cinn
int main(){
iostream::sync_with_stdio(0)/*,cin.tie(0),cout.tie(0)*/;
cin>>n>>m>>k;
const auto rdmtx = [](ll (&mtx)[maxn][maxn],ll const &n,ll const &m){
for(ll i{1};i<=n;i++){
for(ll j{1};j<=m;j++){
cin>>mtx[i][j];
}
}
};
const auto pmtx = [](ll (&mtx)[maxn][maxn],ll const &n,ll const &m){
for(ll i{1};i<=n;i++){
for(ll j{1};j<=m;j++){
cout<<mtx[i][j]<<' ';
}
cout<<'\n';
}
};
rdmtx(a,n,m);
rdmtx(b,m,k);
for(ll l{1};l<=k;l++)
for(ll i{1};i<=n;i++)
for(ll j{1};j<=m;j++){
c[i][l]+=a[i][j]*b[j][l];
}
pmtx(c,n,k);
}