首页 > 其他分享 >POJ - 2029 Get Many Persimmon Trees(暴力水题)

POJ - 2029 Get Many Persimmon Trees(暴力水题)

时间:2023-04-07 11:11:28浏览次数:47  
标签:map 水题 Get int Many scanf d% 矩阵 include


题目大意:给你一个矩阵,矩阵上面有N个柿子树,现在要求你画一个s*t的矩阵,使得这个矩阵内的柿子树达到最多

解题思路:100 * 100,直接暴力

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;

int n, w, h, s, t;
int map[N][N];

void init() {
    scanf("%d%d", &w, &h);
    memset(map, 0, sizeof(map));

    int x, y;
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        map[x][y] = 1;
    }
    scanf("%d%d", &s, &t);
}

void solve() {
    int ans = 0;

    for (int i = 1; i + s - 1 <= w; i++)
        for (int j = 1; j + t - 1 <= h; j++) {
            int cnt = 0;
            for (int k = i; k < i + s; k++)
                for (int l = j; l < j + t; l++)
                    if (map[k][l]) cnt++;
            ans = max(cnt, ans);
        }
    printf("%d\n", ans);
}

int main() {
    while (scanf("%d", &n) != EOF && n) {
        init();
        solve();
    }
    return 0;
}


标签:map,水题,Get,int,Many,scanf,d%,矩阵,include
From: https://blog.51cto.com/u_10970600/6175550

相关文章

  • ZOJ - 2421 Recaman's Sequence(打表水题)
    题目大意:A0=0Am=A(m-1)-m,如果Am小于0或者Am前面已经出现过了,那么Am=A(m-1)+m解题思路:打表水题我用的是map,纪录数是否出现过了#include<cstdio>#include<cstring>#include<map>usingnamespacestd;constintN=500010;typedeflonglongLL;map<LL,int>Ma......
  • 两种保存状态的方法getSharedPreferences和onSaveInstanceState
    虽然这些东西很简单有时候还真的让你搞混@OverrideprotectedvoidonPause(){super.onPause();SharedPreferencesprefs=getSharedPreferences("X",MODE_PRIVATE);Editoreditor=prefs.edit();editor.putString("lastAct......
  • UnityWebRequest-与后台数据传输Get/Post请求
    现在越来越多的项目都要用到登录、成绩上传等功能,涉及到Unity与后台接口之前调用与发送,下面着重介绍Unity自带的Http请求,包含Get/Post请求(表单、json、有头文件的请求。)一、Get请求直接填入接口地址,即可接收后台返回的json数据,新手在这里可能有点懵,不知道接口是什么意思,这里接口......
  • Dlg_GetNeighbourFaces ui 逻辑
    QGridLayout*gridLayout_3;QGroupBox*groupBox;QFormLayout*formLayoutformLayout->setWidget(1,QFormLayout::LabelRole,labelfillet);formLayout->setWidget(2,QFormLayout::SpanningRole,treeView);formLayout->setWidget(3,QFormLayout::LabelRole,......
  • DXImageTransform.Microsoft.AlphaImageLoader(滤镜实例)
    <html><head><scripttype="text/javascript">functionselectFile(oFile,imgname){if(oFile.value=="")return;varpos=oFile.value.lastIndexOf(".");varpos2=oFile.value.la......
  • NuGet Response status code does not indicate success: 401 (Unauthorized).
    Retrying'FindPackagesByIdAsyncCore'forsource'https://nexus-cn/repository/nuget-group/FindPackagesById()?id='Moq'&semVerLevel=2.0.0'.Anerroroccurredwhilesendingtherequest.Therequestwasaborted:Therequest......
  • The Many Ways To Call Axes In Matplotlib
    %matplotlibwidgetfromIPython.displayimportdisplay,HTMLimportrefrompathlibimportPathimportcv2importnumpyasnpimportmatplotlib.pyplotaspltfrompprintimportpprintimportclipboardimportpandasaspdimportconcurrent.futuresimportt......
  • Flutter之GetX之路由管理
    GetX之路由管理GetX有一套完整的路由管理,并且不需要context上下文,API非常简洁直接导航导航到新的页面Get.to(NextScreen());返回,此方法可以用于关闭SnackBars、Dialogs、BottomSheets或任何你通常会用Navigator.pop(context)关闭的东西。Get.back();进入下一个页面并将上......
  • Flutter之GetX之GetConnect
    Flutter之GetX之GetConnectGetConnect可以便捷的通过http或websockets进行前后台通信。默认配置能轻松的通过extendGetConnect就能使用GET/POST/PUT/DELETE/SOCKET方法与RestAPI或websockets通信。classUserProviderextendsGetConnect{//GetrequestFuture<Respo......
  • Flutter之GetX之国际化
    Flutter之GetX之国际化在GetMaterialApp中设置GetMaterialApp(locale:Get.deviceLocale,translations:Messages(),fallbackLocale:constLocale("en_US"),)其中设置的locale为用Get.deviceLocale设置的设备语言translations设置的为我们继承Translation......