UVA 11044-Searching for Nessy
题目大意:n*m的格子最多放多少个3*3的大格子。
解题思路:(n/3)*(m/3)
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
long long int n;
cin >> n;
while(n--) {
long long int a, b;
long long int x, y;
scanf("%lld%lld", &a, &b);
x = (a - 2) / 3;
y = (b - 2) / 3;
if((a - 2) % 3 != 0)
x++;
if((b - 2) % 3 != 0)
y++;
printf("%lld\n", x * y);
}
return 0;
}

本文介绍了解决UVA11044问题的方法,该问题是求在一个n*m的格子中能放置的最大3*3格子的数量。通过简单的数学运算(n/3)*(m/3)来解决此问题,并给出了C++实现代码。

374

被折叠的 条评论
为什么被折叠?



