• C. Target Practice


    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$ ($1t1000$) — 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 } 取其中的最小值,对所有射中点求和即可。

    1. #include
    2. int main()
    3. {
    4. int t;
    5. scanf("%d", &t);
    6. char c;
    7. scanf("%c", &c);
    8. for (int i = 0; i < t; i++)
    9. {
    10. int s = 0;
    11. for (int j = 0; j < 10; j++)
    12. {
    13. for (int k = 0; k < 10; k++)
    14. {
    15. scanf("%c", &c);
    16. if (c == 'X')
    17. {
    18. int a = 5;
    19. if (j + 1 < a)
    20. {
    21. a = j + 1;
    22. }
    23. if (10 - j < a)
    24. {
    25. a = 10 - j;
    26. }
    27. if (k + 1 < a)
    28. {
    29. a = k + 1;
    30. }
    31. if (10 - k < a)
    32. {
    33. a = 10 - k;
    34. }
    35. s += a;
    36. }
    37. }
    38. scanf("%c", &c);
    39. }
    40. printf("%d\n", s);
    41. }
    42. return 0;
    43. }

  • 相关阅读:
    Dockerfile讲解
    MFC使用友元函数访问窗体类成员变量
    [NLP] LLM---<训练中文LLama2(二)>扩充LLama2词表构建中文tokenization
    [python刷题模板] 珂朵莉树 ODT (基于支持随机访问的跳表
    数字人民币如何将支付宝钱包余额转入到微信支付钱包余额?
    蓄电池建模、分析与优化(Matlab代码实现)
    葡萄糖-聚乙二醇-阿奇霉素,Azithromycin-PEG-Glucose
    java版工程管理系统Spring Cloud+Spring Boot+Mybatis实现工程管理系统
    MySQL 学习笔记
    K8s 部署 Nginx
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/134045138