White rectangles time Limit:2 Seconds Memory limit:65536 KB You is given a chessboard made up of n squares by N sq Uares with equal size. Some of the squares are colored black, and the others is colored white. Please write a program to calculate the number of rectangles which is completely made up of white squares.
Input
There is multiple test cases. Each test case is begins with an integer n (1 <= n <=), the board size. The following n lines, each with N characters, has only a valid character values:
#-(Sharp) representing a black square;
. -(point) representing a white square.
Process to the end of file.
Output
For each test case in the input, your program must output the number of the white rectangles, as shown in the sample output.
Sample Input
2
.#
..
4
.. #.
##.#
.#..
.#.#
Sample Output
5
15
#include <stdio.h>
#include <string.h>
#define MAX
#define INF 0x7fffffff
Char A[max] [MAX];
int Count[max][max];
int n;
int min (int x,int y)
{
return x<y?x:y;
}
void sum ()
{
int i,j;
for (i = 1;i <= n, i++)
{for
(j = 1;j <= N; j + +)
{
if (a[i][j] = = '. ')
{
Count[i][j] = count[i][j-1] + 1;
}}} int Min ()
{
int i,j,k;
int ans = 0;
for (i = 1;i <= n, i++)
{for
(j = 1;j <= N; j + +)
{
int m = inf;
for (k = i;k <= n && count[k][j]; k++)//1 Column 1 column judgment middle break end
{
m = min (M,count[k][j]);
Ans + = m
;
}}} return ans;
}
int main ()
{
int i;
while (scanf ("%d", &n)!=eof)
{for
(i = 1;i <= n; i++)
scanf ("%s", A[i] + 1);
memset (Count,0,sizeof (count));
Sum ();
printf ("%d\n", Min ());
}
return 0;
}