piyuhan666 @ 2024-08-09 10:39:31
#include<bits/stdc++.h>
using namespace std;
int n,a[130][130],s[10000][10000],mx=-1e9;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>a[i][j];
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
mx=max(mx,s[i][j]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=i;k++){
for(int h=1;h<=j;h++){
int x1=i,x2=k,y1=j,y2=h;
int t=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
mx=max(t,mx);
}
}
}
}
printf("%d",mx);
return 0;
}
by lovely_codecat @ 2024-08-09 10:45:19
x1和x2反了
@piyuhan666
by piyuhan666 @ 2024-08-09 10:46:07
能跟我具体讲讲吗
by piyuhan666 @ 2024-08-09 14:19:06
#include<bits/stdc++.h>
using namespace std;
int n,a[130][130],s[10000][10000],mx=-1e9;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>a[i][j];
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
mx=max(mx,s[i][j]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
for(int h=1;h<=n;h++){
int x1=k,x2=i,y1=h,y2=j;
int t=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
mx=max(t,mx);
}
}
}
}
printf("%d",mx);
return 0;
}```
还是不对
by zenglicheng666 @ 2024-08-25 19:12:31
@piyuhan666 可恶,皮语涵
by piyuhan666 @ 2024-08-26 09:39:47
@zenglicheng666 怎么了
by piyuhan666 @ 2024-08-26 09:50:07
@lovely_codecat 已过,谢谢大佬