首页 技术 正文
技术 2022年11月15日
0 收藏 816 点赞 2,683 浏览 1354 个字

Black and white painting

题目描述

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 nm 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.

示例输入

8 8 0
8 8 1
9 9 1
40000 39999 0
0 0 0

示例输出

0
1
2
799700028

代码:

#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>using namespace std;int main()
{
int n, m, c;
long long int ans=0;
int i, j; while(scanf("%d %d %d", &n, &m, &c)!=EOF)
{
if(n==0 && m==0 &&c==0 )
break;
ans=0;
int flag;
if(c==1) // bai
flag=1;
else
flag=0;
int dd, ff;
for(i=m; i>=8; i--)
{
if(flag==1)
{
dd=(n-8)/2+1;
ans+=dd; flag=0;
}
else
{
ff=n-1;
if(ff<8)
{
dd=0;
ans+=dd;
flag=1;
}
else
{
dd=(ff-8)/2+1;
ans+=dd; flag=1;
}
}
}
printf("%lld\n", ans );
}
return 0;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295