标签:des style blog http color java os io
Time Limit: 30000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2904 Accepted Submission(s):
1457
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 #define N 1005 5 int arr[N][N]; 6 7 int main() 8 { 9 int t, m, n, x, y; 10 int i, j, k, l, sum, max; 11 scanf("%d",&t); 12 while(t--) 13 { 14 scanf("%d%d%d%d",&m,&n,&x,&y); 15 memset(arr,0,sizeof(arr)); 16 for(i=1; i<=m; i++) 17 for(j=1; j<=n; j++) 18 { 19 scanf("%d",&arr[i][j]); 20 arr[i][j] += arr[i][j-1]; //每一列等于前面所有列对应的和 21 } 22 sum = 0; 23 max = 0; 24 for(i=x; i<=m; i++) 25 { 26 for(j=1; j<=n-y; j++) 27 { 28 for(k=j; k<j+y; k++) 29 sum += (arr[k][i]-arr[k][i-x]); //括号里的所有可能得x列的和 30 if(sum>max) 31 max = sum; 32 sum = 0; 33 } 34 } 35 printf("%d\n",max); 36 } 37 return 0; 38 }
相似的题目还有杭电1081 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1081
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/yazhou/p/3916814.html