luogu#P4813. [CCO 2014] Troy 与三角形
[CCO 2014] Troy 与三角形
Problem Description
This problem is translated from CCO 2014 Day 1 T1 “Troyangles”.
Troy likes triangles, so he especially likes counting triangles. He has an grid consisting of . and #. Help him count how many triangles made only of # appear in the grid. A triangle looks like this:
#
# ###
#, ###, #####, ...
More formally, a triangle of height has rows, where is a positive integer. Row has # characters . The rows are centered above each other, so the triangle is symmetric about its vertical center line.
Input Format
The first line contains an integer , the size of the grid. The next lines each contain characters describing the grid.
Output Format
Output the number of triangles in the grid.
5
.....
.###.
.###.
#####
.....
16
Hint
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5