本文介绍: 【代码】CCFCSP试题编号:202104-2试题名称:邻域均值

#include <iostream>
using namespace std;
int A[605][605];
int ans = 0;
int acc[605][605];
int main()
{
    int n, L, r, t;
    cin >> n >> L >> r >> t;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> A[i][j];
            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1] + A[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int left = max(j - r, 1);
            int right = min(j + r, n);
            int upper = max(i - r, 1);
            int down = min(i + r, n);
            int near = acc[down][right] - acc[down][left - 1] - acc[upper - 1][right] + acc[upper - 1][left - 1];
            if (near <= (down - upper + 1) * (right - left + 1) * t) ans++;
        }
    }
    cout << ans << endl;
}

 

原文地址:https://blog.csdn.net/jsjsjejsj/article/details/134736486

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_45956.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注