题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<iostream>
using namespace std;
const int N = 610;
int a[N][N],s[N][N];
int n, l, r, t;
int main()
{
int res = 0;
cin >> n >> l >> r >> t ;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
cin>>a[i][j];
}
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
}
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
int re, m;
int x1, y1, x2, y2;
x1 = max(1, i - r);
y1 = max(1, j - r);
x2 = min(n, i + r);
y2 = min(n, j + r);
re = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
m = (y2 - y1 + 1) * (x2 - x1 + 1);
if(re <= t * m)
{
res ++;
}
}
}
cout << res;
}