OpenJudge

03:Weiming Ice Rink

总时间限制:
1000ms
内存限制:
65536kB
描述

Every winter, Weiming lake will freeze into an ice rink. This year, when you pass by the Weiming lake, you find that only parts of the lake are frozen. You want to know how many pieces of ice there are.

Assume that the lake is a n * m square that can be divided into n * m grids, each grid may be frozen or not frozen. A frozen area is made up of connected frozen grids. Being connected means that the two grids are  adjacent in the horizontal direction, vertical direction or diagonal direction.


输入
There are several cases.
For each case, the first line is two integer n, m (1 <= n <= 100, 1 <= m <= 100), which represents the number of rows and columns of the lake.
In the next n lines:
Each line contains m characters representing the status of this grid, where "*" means not frozen and "@" means frozen.
When n = 0, the input ends.
输出
Each case contains a number denoting the number of frozen areas.
样例输入
1 1
*
3 5
*@*@*
**@**
*@*@*
1 8
@@****@*
5 5
****@
*@@*@
*@**@
@@@*@
@@**@
0 0
样例输出
0
1
2
2

01 Use "long long" to calculate the answer
05 Expected Value of an Expression: Ai is less than 2^20

全局题号
15297
提交次数
56
尝试人数
43
通过人数
42