一个国外的竞赛题(USACO2021FebruaryContest,Silver Problem3,JustGreenEnough)Writeup

这是一篇关于USACO2021竞赛中Silver级别第三题的解析,题目要求在N*N的草地上找到所有绿色度最小值为100的矩形子区域,总数可能超过32位整数范围,需要使用64位数据类型。文章讨论了如何确定满足条件的不同矩形数量,并提供了C++和Python的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Farmer John's pasture can be regarded as an N x N grid(1<=n<=500)of square "cells" of grass(picture a huge chessboard).
Due to soil variability,the grass in some cells is greener than in others.Each cell(i,j)is described by an integer level of greenness G(i,j),rangeing from 1...200

Farmer John wants to take a photograph of a rectangular sub-grid of his pasture.He wants to be sure the sub-grid looks
sufficiently green, but not ridiculously green,so he decides to photograph a sub-grid for which the minimum value of G is exactly
100.Please help him determine how many different photographs he could possibly take.A sub-grid can be as large as the entire
pasture or as small as a single grid cell(there are N**2 *(N+1)**2/ 4)different sub-grids in total--note that this number might be too
large to store in a standard 32-bit integer,so you might need to use 64-bit integer data types like a "long long" in C++)

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值