ZOJ2975 伪数组压缩+组合数
Kinds of Fuwas
Time Limit:
2 Seconds Memory Limit:65536 KB
In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China as well as becoming a festival for people all over the world.
The official mascots of Beijing 2008 Olympic Games are Fuwa, which are named as Beibei, Jingjing, Haunhuan, Yingying and Nini. Fuwa embodies the natural characteristics of the four most popular animals in China -- Fish, Panda,
Tibetan Antelope, Swallow -- and the Olympic Flame. To popularize the official mascots of Beijing 2008 Olympic Games, some volunteers make a PC game with Fuwa.

As shown in the picture, the game has a matrix of Fuwa. The player is to find out all the rectangles whose four corners have the same kind of Fuwa. You should make a program to help the player calculate how many such rectangles
exist in the Fuwa matrix.
Input
Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <=T
<= 50) which is the number of test cases. And it will be followed byT consecutive test cases.
The first line of each test case has two integersM andN (1 <=M,N
<= 250), which means the number of rows and columns of the Fuwa matrix. And then there areM lines, each hasN
characters, denote the matrix. The characters -- 'B' 'J' 'H' 'Y' 'N' -- each denotes one kind of Fuwa.
Output
Results should be directed to standard output. The output of each test case should be a single integer in one line, which is the number of the rectangles whose four corners have the same kind of Fuwa.
Sample Input
2
2 2
BB
BB
5 6
BJHYNB
BHBYYH
BNBYNN
JNBYNN
BHBYYH
Sample Output
1
8
http://blog.csdn.net/mengxiang000000/article/details/51169341 题目大意:给你一个n*m的矩阵,里边有五种福娃,让你在图中找四个角都是一样福娃的矩形个数。 思路: 我们枚举两行,这样如果上边一行和下边一行的相同位子字母相同的话,这样就保证了有一条边符合矩形了。 假如这样的两行: BBBB BBBB 一共有四条竖着的边符合条件,辣么能够组成多少个矩形呢?用排列组合的话来说,很简单,就是Cn2.辣么我们这个时候只要枚举三层for即可。
ZOJ2975 伪数组压缩+组合数的更多相关文章
- python 全栈开发,Day51(常用内置对象,函数,伪数组 arguments,关于DOM的事件操作,DOM介绍)
昨日内容回顾 1.三种引入方式 1.行内js <div onclick = 'add(3,4)'></div> //声明一个函数 function add(a,b){ } 2. ...
- 前端JavaScript(2) --常用内置对象,函数,伪数组 arguments,关于DOM的事件操作,DOM介绍
昨日内容回顾 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...
- js伪数组及转换
什么是伪数组 能通过Array.prototype.slice转换为真正的数组的带有length属性的对象. 这种对象有很多,比较特别的是arguments对象,还有像调用getElementsByT ...
- 将HTMLCollection/NodeList/伪数组转换成数组
这里把符合以下条件的对象称为伪数组(ArrayLike) 1,具有length属性 2,按索引方式存储数据 3,不具有数组的push,pop等方法 如 1,function内的arguments . ...
- 关于js中伪数组
伪数组: 具有length属性: 按索引方式存储数据: 不具有数组的push().pop()等方法: 伪数组无法直接调用数组方法或期望length属性有什么特殊的行为,不具有数组的push().pop ...
- 在Javascript中什么是伪数组?如何将伪数组转化为标准数组?
答案: 伪数组(类数组):无法直接调用数组方法或期望length属性有什么特殊的行为,但仍可以对真正数组遍历方法来遍历它们.典型的是函数的argument参数,还有像调用getElementsByTa ...
- js中的伪数组
一, 伪数组 1. 具有length属性 2. 按索引方式存储数据 3. 不具有数组的方法, 比如push(),pop()等 二, 生成伪数组的方法 在js中生成伪数组的方法比较多 1. functi ...
- Java利用递归算法统计1-6的数组排列组合数
Java利用递归算法统计1-6的数组排列组合数 1.设计源码 /** * @Title:ArrayCombination.java * @Package:com.you.data * @Descrip ...
- 09-JavaScript之伪数组arguments
JavaScript之伪数组arguments arguments代表的是实参.有个讲究的地方是:arguments只在函数中使用. 1.返回函数实参的个数 使用argument.length方法返回 ...
随机推荐
- 正则语言引擎:一个简单LEX和YACC结合运用的实例
本文先描述了LEX与YACC的书写方法.然后利用LEX与YACC编写了一个简单正则语言的引擎(暂时不支持闭包与或运算),生成的中间语言为C语言. 正则引擎应直接生成NFA或DFA模拟器的输入文件,但在 ...
- Swiper 滑动
1.http://www.swiper.com.cn/download/ 下载Swiper.JS Swiper.CSS 2.引入项目,添加html <div class="cont ...
- NHibernate教程(21)——二级缓存(下)
本节内容 引入 使用NHibernate二级缓存 启用缓存查询 管理NHibernate二级缓存 结语 引入 这篇我还继续上一篇的话题聊聊NHibernate二级缓存剩下的内容,比如你修改.删除数据时 ...
- JS中的运算符和JS中的分支结构
JS中的运算符 1.算术运算(单目运算符) + .-.*. /. %取余.++自增 .--自减 +:两种作用,链接字符串/加法运算.当+两边全为数字时,进行加法运算:当+两边有任意一边为字符串时,起链 ...
- 团队作业6——展示博客(Alpha版本)
Deadline: 2017-5-7 22:00PM,以博客发表日期为准 评分基准: 按时交 - 有分,检查的项目包括后文的四个方面 团队成员介绍 Alpha阶段进展 团队合作,各成员分工 Beta阶 ...
- Swing-setMaximumSize()用法-入门
与setMinimumSize()一同讨论.顾名思义,这两个函数用于设置窗体的最大.最小值.然而测试发现,setMaximumSize()直接作用于JFrame时,无法实现其预定功能,setMinim ...
- 201521044091 《Java程序设计》第2周学习总结
1本章学习总结 (1)一些java的基本语法 (2)java API文件 (3)使用码云管理自己的代码 2.Java Q&A 1)使用Eclipse关联jdk源代码(截图),并查看String ...
- paxos 算法原理学习
下面这篇关于paxos分布式一致性的原理,对入门来说比较生动有趣,可以加深下影响.特此博客中记录下. 讲述诸葛亮的反穿越 0.引子 一日,诸葛亮找到刘备,突然献上一曲<独角戏>,而后放声大 ...
- 自定义BaseServlet利用反射
比较完美一点的BaseServlet package com.yangwei.mvc.servlet; import java.io.IOException; import java.lang.ref ...
- Apache POI
Apache POI 用Java编写的免费开源的跨平台的 Java API,Apache POI提供API给Java程式对Microsoft Office格式档案读和写的功能.POI为"Po ...