301219: CF228C. Fractal Detector

Memory Limit:256 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Fractal Detector

题意翻译

### 题目描述: Vasya是个喜欢分型的男孩 他会先画出一个2$\times$2的白色格子,然后在上面任意的涂色。这是他的第一次操作。 接下来的若干次操作,他把原先黑色的格子变为2$\times$2的黑格子,原先白色的格子变成刚开始涂好色的颜色。 比如Vasya刚开始把2$\times$2的右上角的格子涂黑,他能得到以下图形 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/e8422806af6330609da67545ef59f385e8f81169.png) 图中,Vasya一共做了三次操作 一天Vasya累了,他不想画分形图形了,于是他随手画了一个图,想要知道里面有多少个至少经过两次操作的分形图形 ### 输入输出格式 **输入格式:** 第一行两个数n,m(n,m<=500),表示Vasya随手画的图形大小 接下来n行,每行m个字符,其中"*"表示黑色,"."表示白色 **输出格式:** 一个数,表示给出的图中有多少个至少经过两次操作的分形图形 ### 说明 对于第一个样例,如下图红色、蓝色、绿色所示所示 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/0e3ee6f0bc356a0362f898d820ceb6d14269c83c.png) 对于第二个样例,并没有合法的分形图形 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/52949284a400689262d98e354fadec0c60f26f1b.png)

题目描述

Little Vasya likes painting fractals very much. He does it like this. First the boy cuts out a $ 2×2 $ -cell square out of squared paper. Then he paints some cells black. The boy calls the cut out square a fractal pattern. Then he takes a clean square sheet of paper and paints a fractal by the following algorithm: 1. He divides the sheet into four identical squares. A part of them is painted black according to the fractal pattern. 2. Each square that remained white, is split into 4 lesser white squares, some of them are painted according to the fractal pattern. Each square that remained black, is split into 4 lesser black squares. In each of the following steps step 2 repeats. To draw a fractal, the boy can make an arbitrary positive number of steps of the algorithm. But he need to make at least two steps. In other words step 2 of the algorithm must be done at least once. The resulting picture (the square with painted cells) will be a fractal. The figure below shows drawing a fractal (here boy made three steps of the algorithm). ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF228C/e8422806af6330609da67545ef59f385e8f81169.png)One evening Vasya got very tired, so he didn't paint the fractal, he just took a sheet of paper, painted a $ n×m $ -cell field. Then Vasya paint some cells black. Now he wonders, how many squares are on the field, such that there is a fractal, which can be obtained as described above, and which is equal to that square. Square is considered equal to some fractal if they consist of the same amount of elementary not divided cells and for each elementary cell of the square corresponding elementary cell of the fractal have the same color.

输入输出格式

输入格式


The first line contains two space-separated integers $ n,m $ $ (2<=n,m<=500) $ — the number of rows and columns of the field, correspondingly. Next $ n $ lines contain $ m $ characters each — the description of the field, painted by Vasya. Character "." represents a white cell, character "\*" represents a black cell. It is guaranteed that the field description doesn't contain other characters than "." and "\*".

输出格式


On a single line print a single integer — the number of squares on the field, such that these squares contain a drawn fractal, which can be obtained as described above.

输入输出样例

输入样例 #1

6 11
......*.***
*.*.*....**
.***....*.*
..***.*....
.*.*.....**
......*.*..

输出样例 #1

3

输入样例 #2

4 4
..**
..**
....
....

输出样例 #2

0

说明

The answer for the first sample is shown on the picture below. Fractals are outlined by red, blue and green squares. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF228C/0e3ee6f0bc356a0362f898d820ceb6d14269c83c.png)The answer for the second sample is 0. There is no fractal, equal to the given picture. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF228C/52949284a400689262d98e354fadec0c60f26f1b.png)

Input

题意翻译

### 题目描述: Vasya是个喜欢分型的男孩 他会先画出一个2$\times$2的白色格子,然后在上面任意的涂色。这是他的第一次操作。 接下来的若干次操作,他把原先黑色的格子变为2$\times$2的黑格子,原先白色的格子变成刚开始涂好色的颜色。 比如Vasya刚开始把2$\times$2的右上角的格子涂黑,他能得到以下图形 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/e8422806af6330609da67545ef59f385e8f81169.png) 图中,Vasya一共做了三次操作 一天Vasya累了,他不想画分形图形了,于是他随手画了一个图,想要知道里面有多少个至少经过两次操作的分形图形 ### 输入输出格式 **输入格式:** 第一行两个数n,m(n,m<=500),表示Vasya随手画的图形大小 接下来n行,每行m个字符,其中"*"表示黑色,"."表示白色 **输出格式:** 一个数,表示给出的图中有多少个至少经过两次操作的分形图形 ### 说明 对于第一个样例,如下图红色、蓝色、绿色所示所示 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/0e3ee6f0bc356a0362f898d820ceb6d14269c83c.png) 对于第二个样例,并没有合法的分形图形 ![](https://cdn.luogu.org/upload/vjudge_pic/CF228C/52949284a400689262d98e354fadec0c60f26f1b.png)

加入题单

上一题 下一题 算法标签: