内部赛3 B Black and white painti…

来源:互联网 发布:java 判断日期相等 编辑:程序博客网 时间:2024/06/03 15:55

Time Limit: 1000MS Memory limit:65536K

题目描述

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

Since you are bored, you wonder howmany 8× 8 chessboards are embedded within this painting. The bottom right cornerof a chess board must always be white.

输入

The inputcontains several test cases. Each test case consists of one linewith three integers n, m and c.(8≤ n, m ≤ 40000), where n is thenumber of rows of the painting, and m is thenumber of columns of the painting. c isalways 0 or 1,where 0 indicates thatthe bottom right corner of the painting is black, and 1 indicates thatthis corner is white.

The last test case is followed by a linecontaining three zeros.

输出

For each testcase, print the number of chess boards embedded within the givenpainting.


示例输入

8 8 08 8 19 9 140000 39999 00 0 0

示例输出

012799700028

代码:

#include<iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n, m, c,ans, p, q, flag1, flag2;
    while(scanf("%d%d%d", &n, &m,&c) != EOF && n&& m)
    {
       p = n - 7;
       q = m - 7;
       flag1 = p % 2;
       flag2 = q % 2;
       ans = p * q / 2;
       if (flag1 && flag2)
       {
           ans = ans + 1;
       }
       if (c == 0)
       {
           ans = p * q - ans;
       }
       printf("%d\n", ans);
    }
    return0;
}