因为痛,所以叫青春

我有一个梦想:穷屌丝变身富屌丝
Black and white painting 一道很简单的规律题目
View Code
Black and white painting

Time Limit: 1000MS Memory limit: 65536K

题目描述

You are visiting the Centre Pompidou which contains a lot of modern paintings. In particular you notice one painting which consists solely of black and white squares, arranged in rows and columns like in a chess board (no two adjacent squares have the same colour). By the way, the artist did not use the tool of problem A to create the painting.

Since you are bored, you wonder how many 8 × 8 chess boards are embedded within this painting. The bottom right corner of a chess board must always be white.

输入

The input contains several test cases. Each test case consists of one line with three integers n, m and c. (8 ≤ n, m ≤ 40000), where n is the number of rows of the painting, and m is the number of columns of the painting. c is always 0 or 1, where 0 indicates that the bottom right corner of the painting is black, and 1 indicates that this corner is white.

The last test case is followed by a line containing three zeros.

输出

For each test case, print the number of chess boards embedded within the given painting.

其实这道题目只需要把他所描述的那张图,空出上面的七行,和左面的七列,让后看剩下的有多少个白色的格子就行了,但是对于右下角给定的颜色不同或许会有一点点不同~~具体怎么操作就看代码了~~

#include<stdio.h>
void main()
{
int m,n,t;
while(scanf("%d%d%d",&m,&n,&t)&&(m||t||n))
{
if(m<8 || n<8)
printf("0\n");
else
{
//此处为去掉前(七行七列)的操作
m -= 7;
n -= 7;
//如果右下角是白色的就把剩下的行列数乘积+1
if(t)
printf("%d\n",(m*n+1)/2);
else
printf("%d\n",m*n/2);
}
}
}

只供参考,禁止copy

 

 

posted on 2012-03-18 09:44  Nice!  阅读(446)  评论(0编辑  收藏  举报