time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
A $10×10$ target is made out of five "rings" as shown. Each ring has a different point value: the outermost ring — 1 point, the next ring — 2 points, ..., the center ring — 5 points.
Vlad fired several arrows at the target. Help him determine how many points he got.
Input
The input consists of multiple test cases. The first line of the input contains a single integer $t$ ($1≤t≤1000$) — the number of test cases.
Each test case consists of 10 lines, each containing 10 characters. Each character in the grid is either $X$ (representing an arrow) or $.$ (representing no arrow).
Output
For each test case, output a single integer — the total number of points of the arrows.
Example
input
Copy
4
X.........
..........
.......X..
.....X....
......X...
..........
.........X
..X.......
..........
.........X
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
....X.....
..........
..........
..........
..........
..........
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
output
Copy
17 0 5 220
Note
In the first test case, there are three arrows on the outer ring worth 1 point each, two arrows on the ring worth 3 points each, and two arrows on the ring worth 4 points each. The total score is $3×1+2×3+2×4=17$.
In the second test case, there aren't any arrows, so the score is $0$.
3
解题说明:此题是一道几何题,图从外到里依次为1-5分,X为射中了这个点,求总分。设某点坐标x,y,则该点分值为 { x,y,10-x+1,10-y+1 } 取其中的最小值,对所有射中点求和即可。
- #include
- int main()
- {
- int t;
- scanf("%d", &t);
- char c;
- scanf("%c", &c);
- for (int i = 0; i < t; i++)
- {
- int s = 0;
- for (int j = 0; j < 10; j++)
- {
- for (int k = 0; k < 10; k++)
- {
- scanf("%c", &c);
- if (c == 'X')
- {
- int a = 5;
- if (j + 1 < a)
- {
- a = j + 1;
- }
- if (10 - j < a)
- {
- a = 10 - j;
- }
- if (k + 1 < a)
- {
- a = k + 1;
- }
- if (10 - k < a)
- {
- a = 10 - k;
- }
- s += a;
- }
- }
- scanf("%c", &c);
- }
- printf("%d\n", s);
- }
- return 0;
- }