zoukankan      html  css  js  c++  java
  • Sicily 1795 Table tennis

    几何题. 仔细一点即可通过. 需要注意的是, 为了提高效率, 需要对每次hit的坐标进行预处理. 即判断该点是否在某个圆的范围(包住圆方形)内, 如果不在不计算, 如果在的话判断出这个hit的坐标与所在圆的圆心的距离. 若距离小于该圆半径, 那么在圆内, 算是击中.

    代码
    /* platero 2010-11-5 */
    #include
    <stdio.h>
    #include
    <math.h>
    #define MAXHITS 60

    typedef
    struct Point
    {
    int x;
    int y;
    };

    int main()
    {
    int t, n, i, hit_point;
    struct Point curhit;
    scanf(
    "%d", &t);
    while(t--)
    {
    hit_point
    = 0;
    scanf(
    "%d", &n);
    /* 输入hits座标 */
    for(i = 0; i < n; i++)
    {
    scanf(
    "%d%d", &curhit.x, &curhit.y);
    /* 是否在大圆范围内 */
    if(curhit.x > 10 && curhit.x < 50)
    {
    if(curhit.y > 10 && curhit.y < 50)
    {
    if(pow((curhit.x - 30),2) + pow((curhit.y-30), 2) < 400)
    {
    hit_point
    += 1;
    }
    }
    }
    else if(curhit.x > 90 && curhit.x < 110)
    {
    if(curhit.y > 20 && curhit.y < 40)
    {
    if(pow((curhit.x - 100),2) + pow((curhit.y-30), 2) < 100)
    {
    hit_point
    += 2;
    }
    }
    }
    else if(curhit.x > 165 && curhit.x < 175)
    {
    if(curhit.y > 25 && curhit.y < 35)
    {
    if(pow((curhit.x - 170),2) + pow((curhit.y-30), 2) < 25)
    {
    hit_point
    += 3;
    }
    }
    }
    }
    printf(
    "%d\n", hit_point);
    }
    return 0;
    }

  • 相关阅读:
    [Luogu] 借教室
    [Luogu] 子共七
    [Luogu] 让我们异或吧
    【bzoj1030】[JSOI2007]文本生成器
    HDU3068 最长回文
    【bzoj2342】[Shoi2011]双倍回文
    【NOIP2012】借教室
    HDU2203 亲和串
    【POJ2001】Shortest Prefixes
    vodevs3031 最富有的人
  • 原文地址:https://www.cnblogs.com/platero/p/1870117.html
Copyright © 2011-2022 走看看