ybt上的题
link
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,ans=0;
cin>>x>>y;
if(x==1){
cin>>x;
cout<<x;
return 0;
}
int **a=new int *[x];
for(int i=0;i<x;i++){
a[i]=new int[y];
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
cin>>a[i][j];
}
}
for(int i=0;i<x;i++){
ans+=a[0][i]+a[x-1][i];
}
for(int i=0;i<y;i++){
ans+=a[i][0]+a[i][y-1];
}
ans-=a[0][0]+a[0][y-1]+a[x-1][0]+a[x-1][y-1] ;
cout<<ans<<endl;
for(int i=0;i<x;i++){
delete[] a[i];
}
delete[] a;
return 0;
}