CF228C.Fractal Detector
普及+/提高
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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:
- He divides the sheet into four identical squares. A part of them is painted black according to the fractal pattern.
- 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).

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.
小瓦西亚非常喜欢绘制分形图。
他的绘制方法如下:首先,他从方格纸上剪下一个 2×2 的方格正方形,然后将其中某些格子涂成黑色。瓦西亚称这个剪下的正方形为分形模板。接着,他取一张空白的正方形纸张,并按以下算法绘制分形图:
- 将该纸张划分为四个完全相同的正方形;其中一部分正方形根据分形模板被涂成黑色;
- 对于仍保持白色的每个正方形,将其再细分为四个更小的白色正方形,其中一些按分形模板涂黑;而对于仍保持黑色的每个正方形,则将其细分为四个更小的黑色正方形。
在后续每一步中,重复执行第 2 步。为了绘制一个分形图,瓦西亚可以执行任意正整数步该算法,但至少需执行两步——即算法的第 2 步至少需执行一次。最终得到的图形(即带有涂色格子的正方形)即为一个分形图。下图展示了一个分形图的绘制过程(此处瓦西亚共执行了三步算法)。

某天晚上,瓦西亚非常疲惫,因此他并未绘制分形图,而是直接取了一张 n×m 的方格纸,并将其中一些格子涂成了黑色。
现在他想知道:在这张纸上,有多少个子正方形满足如下条件——存在某个按上述方式生成的分形图,且该分形图与该子正方形完全一致。两个图形被视为相等,当且仅当它们所含的基本未分割单元格数量相同,且对应位置上的每个基本单元格颜色完全相同。
输入格式
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 "*".
第一行包含两个以空格分隔的整数 n、m(2 ≤ n, m ≤ 500),分别表示场地的行数和列数。
接下来的 n 行,每行包含 m 个字符——即瓦夏绘制的场地描述。字符 . 表示白色格子,字符 * 表示黑色格子。
保证场地描述中仅包含字符 . 和 *,不包含其他字符。
输出格式
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.

The answer for the second sample is 0. There is no fractal, equal to the given picture.

第一个样例的答案如下面图片所示。分形图案由红色、蓝色和绿色的正方形勾勒出。

第二个样例的答案为 0。不存在与给定图片完全相同的分形图案。

输入解题思路,AI测评打分。不知道怎么写?