解题思路:水题目一枚,直接代码吧,注意的是最外面边界不用考虑
the border cells do not need to be controlled, because Nessy cannot hide there (she is too big).
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int n,m,t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
int a,b;
a=b=0;
if((n-2)%3)
{
a=(n-2)/3+1;
}
else
{
a=(n-2)/3;
}
if((m-2)%3)
{
b=(m-2)/3+1;
}
else
{
b=(m-2)/3;
}
printf("%d\n",a*b);
}
return 0;
}
本文介绍了解决简单编程问题的策略,通过实例分析,展示了如何快速找到解题思路,特别关注边界条件的处理,确保算法的有效性和效率。
175

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



