102800: [AtCoder]ABC280 A - Pawn on a Grid

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

Description

Score : $100$ points

Problem Statement

There is a grid with $H$ rows from top to bottom and $W$ columns from left to right. Each square has a piece placed on it or is empty.

The state of the grid is represented by $H$ strings $S_1, S_2, \ldots, S_H$, each of length $W$.
If the $j$-th character of $S_i$ is #, the square at the $i$-th row from the top and $j$-th column from the left has a piece on it;
if the $j$-th character of $S_i$ is ., the square at the $i$-th row from the top and $j$-th column from the left is empty.

How many squares in the grid have pieces on them?

Constraints

  • $1\leq H,W \leq 10$
  • $H$ and $W$ are integers.
  • $S_i$ is a string of length $W$ consisting of # and ..

Input

The input is given from Standard Input in the following format:

$H$ $W$
$S_1$
$S_2$
$\vdots$
$S_H$

Output

Print the number of squares with pieces as an integer.


Sample Input 1

3 5
#....
.....
.##..

Sample Output 1

3

The following three squares have pieces on them:

  • the square at the $1$-st row from the top and $1$-st column from the left;
  • the square at the $3$-rd row from the top and $2$-nd column from the left;
  • the square at the $3$-rd row from the top and $3$-rd column from the left.

Thus, $3$ should be printed.


Sample Input 2

1 10
..........

Sample Output 2

0

Since no square has a piece on it, $0$ should be printed.


Sample Input 3

6 5
#.#.#
....#
..##.
####.
..#..
#####

Sample Output 3

16

Input

题意翻译

给出一个 $H$ 行 $W$ 列的字符矩阵,输出其中`#`的个数。 translated by @[PineappleSummer](https://www.luogu.com.cn/user/880187)。

Output

问题描述

有一个网格,从上到下有$H$行,从左到右有$W$列。每个方格上有一个棋子或为空。

网格的状态由$H$个字符串$S_1, S_2, \ldots, S_H$表示,每个字符串长度为$W$。

如果$S_i$的第$j$个字符为#,则从上数第$i$行、从左数第$j$列的方格上有一个棋子;
如果$S_i$的第$j$个字符为.,则从上数第$i$行、从左数第$j$列的方格为空。

网格中有多少个方格上有棋子?

约束条件

  • $1\leq H,W \leq 10$
  • $H$和$W$为整数。
  • $S_i$是由#.组成的长度为$W$的字符串。

输入

输入从标准输入给出,格式如下:

$H$ $W$
$S_1$
$S_2$
$\vdots$
$S_H$

输出

输出一个整数,表示有棋子的方格的数量。


样例输入 1

3 5
#.....
......
.##...

样例输出 1

3

以下三个方格上有棋子:

  • 从上数第$1$行、从左数第$1$列的方格;
  • 从上数第$3$行、从左数第$2$列的方格;
  • 从上数第$3$行、从左数第$3$列的方格。

因此,应输出$3$。


样例输入 2

1 10
..........

样例输出 2

0

由于没有方格上有棋子,应输出$0$。


样例输入 3

6 5
#.#.#
....#
..##.
####.
..#..
#####

样例输出 3

16

加入题单

算法标签: