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;
}

sdutoj 2373 Black and white painting( 规律统计计算 3Y )的更多相关文章

  1. 统计计算与R语言的资料汇总(截止2016年12月)

    本文在Creative Commons许可证下发布. 在fedora Linux上断断续续使用R语言过了9年后,发现R语言在国内用的人逐渐多了起来.由于工作原因,直到今年暑假一个赴京工作的机会与一位统 ...

  2. Pandas的函数应用、层级索引、统计计算

    1.Pandas的函数应用 1.apply 和 applymap 1. 可直接使用NumPy的函数 示例代码: # Numpy ufunc 函数 df = pd.DataFrame(np.random ...

  3. sql: T-SQL 统计计算(父子關係,樹形,分級分類的統計)

    ---sql: T-SQL 统计计算(父子關係,樹形,分級分類的統計) ---2014-08-26 塗聚文(Geovin Du) CREATE PROCEDURE proc_Select_BookKi ...

  4. Pandas统计计算和描述

    Pandas统计计算和描述 示例代码: import numpy as np import pandas as pd df_obj = pd.DataFrame(np.random.randn(5,4 ...

  5. Python基础-使用range创建数字列表以及简单的统计计算和列表解析

    1.使用函数 range() numbers = list(range[1,6]) print (numbers) 结果: [1,2,3,4,5] 使用range函数,还可以指定步长,例如,打印1~1 ...

  6. CyclicBarrier开启多个线程进行计算,最后统计计算结果

    有一个大小为50000的数组,要求开启5个线程分别计算10000个元素的和,然后累加得到总和 /** * 开启5个线程进行计算,最后所有的线程都计算完了再统计计算结果 */ public class ...

  7. UVa 102 - Ecological Bin Packing(规律,统计)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  8. WUSTOJ 1323: Repeat Number(Java)规律统计

    题目链接:1323: Repeat Number Description Definition: a+b = c, if all the digits of c are same ( c is mor ...

  9. 使用if else if else 统计计算

    package review20140419;/* * 统计一个班级的成绩,并统计优良中差和不及格同学个数以及求平均分 */public class Test2 {    //程序的入口    pub ...

随机推荐

  1. Xamarin.Forms的相对布局RelativeLayout

    Xamarin.Forms的相对布局RelativeLayout   相对布局RelativeLayout是App中常用的布局方式.它是以界面中的某个元素为基准,设置另外一个元素的位置和大小.通过这种 ...

  2. bzoj 4921: [Lydsy六月月赛]互质序列

    4921: [Lydsy六月月赛]互质序列 Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 188  Solved: 110[Submit][Status ...

  3. android权限大全转http://www.cnblogs.com/classic/archive/2011/06/20/2085055.html

    android权限大全转http://www.cnblogs.com/classic/archive/2011/06/20/2085055.html 访问登记属性 android.permission ...

  4. HDOJ1071

    The area   拿到题的第一想法,又是一道水题,知道P1.P2.P3三点的坐标,就能够确定抛物线的公式.确定抛物线的公式就能够进行积分,然后就没有然后了.纯粹的数学题. #include< ...

  5. 【转载】使用事件模型 & libev学习

    参考这篇文章: http://www.ibm.com/developerworks/cn/linux/l-cn-edntwk/ 这里面使用的是 libev ,不是libevent Nodejs就是采用 ...

  6. 配置mysql主从服务器

    参考:https://www.linuxidc.com/Linux/2016-09/135633.htm 一.Master主服务器配置(192.168.1.3) 1.编辑my.cnf(命令查找文件位置 ...

  7. vue2.0 + vux (六)NewsList 资讯页 及 NewsDetail 资讯详情页

    设置代理,避免出现跨域问题 /*设置代理,避免出现跨域问题*/ proxyTable: { '/api':{ target: 'https://www.oschina.net/action/apiv2 ...

  8. Cocos2d-x 避免手工输入项目需要编译的cpp文件到Android.mk里

    手工输入项目需要编译的cpp文件到Android.mk里的缺点 1)繁琐,如果cpp文件很多,简直无法忍受 2)手工输入过程中容易出现错误 3)如果cpp文件更改名称,需要修改Android.mk文件 ...

  9. Sublime Text3 配置设置攻略

    转载:http://cloudbbs.org/forum.php?mod=viewthread&tid=3620 sublime本身功能有限,我们需要装上一些插件使其变得强大.sublime在 ...

  10. Android开发之裁切(拍照+相冊)图像并设置头像小结

    先看效果:                                       watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5 ...