C Target Practice
墨初 知识笔记 79阅读
time limit per test
/span>/span>p>1 second/span>/span>p>memory limit per test/span>/span>p>256 megabytes/span>/span>p>input/span>/span>p>standard input/span>/span>p>output/span>/span>p>standard output/span>/span>p>A $$$10 \times 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./span>/span>p> /span>p/span>/span> fired several arrows at the target. Help him determine how many points he got./span>/span>p>Input/span>/span>p>The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases./span>/span>p>Each test case consists of 10 lines, each containing 10 characters. Each character in the grid is either $$$\texttt{X}$$$ (representing an arrow) or $$$\texttt{.}$$$ (representing no arrow)./span>/span>p>Output/span>/span>p>For each test case, output a single integer — the total number of points of the arrows./span>/span>p>Example/span>/span>p>input/span>/span>p>Copy/span>/span>pre id="id007135920771031632"/span>/pre/span>/span>p>4/span>/span>p>X........./span>/span>p>........../span>/span>p>.......X../span>/span>p>.....X..../span>/span>p>......X.../span>/span>p>........../span>/span>p>.........X/span>/span>p>..X......./span>/span>p>........../span>/span>p>.........X/span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>....X...../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>........../span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>XXXXXXXXXX/span>/span>p>output/span>/span>p>Copy/span>/span>pre id="id003519345643782794">1705220/span>/span>p>Note/span>/span>p>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 \times 1 2 \times 3 2 \times 4 17$$$./span>/span>p>In the second test case, there arent any arrows, so the score is $$$0$$$./span>/span>p/span>/span>/p/span>p>3/span>/span>p>解题说明此题是一道几何题图从外到里依次为1-5分X为射中了这个点求总分。设某点坐标x,y则该点分值为 { xy10-x110-y1 } 取其中的最小值对所有射中点求和即可。/span>/span>pre/span>code class="language-cpp">#include<stdio.h>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;}/span>/pre/span>/span>p/span>/p>标签: