CSP202104_2
目录题目
思路
CSP一贯风格,纯暴力一眼可见的70pts
二维前缀和,没什么要说的
Code
#include<bits/stdc++.h>
using namespace std;
int n;
int l, r, t;
int pre[610][610];
int ans;
int main()
{
cin >> n >> l >> r >> t;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
int val;
cin >> val;
pre[i][j] = pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1] + val;
}
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
int x1 = (i - r >= 1 ? i - r : 1);
int x2 = (i + r <= n ? i + r : n);
int y1 = (j - r >= 1 ? j - r : 1);
int y2 = (j + r <= n ? j + r : n);
int sum = pre[x2][y2] - pre[x1 - 1][y2] - pre[x2][y1 - 1] + pre[x1 - 1][y1 - 1];
int cnt = (x2 - x1 + 1)*(y2 - y1 + 1);
if((double)sum / cnt <= (double)t) ans++;
}
}
cout << ans;
return 0;
}
标签:pre,val,int,610,202104,CSP
From: https://www.cnblogs.com/kevin-chance/p/16720448.html