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;
    }

  • 相关阅读:
    转:Gerrit 学习
    list, set操作
    Dice chrone execise
    【转】terminal 快捷键
    python package list
    爬虫2
    爬虫 1
    django跨表联查传输数据到前端
    vue实现鼠标移入移出事件
    pycharm意外关闭导致报错Unexpected content storage modification:
  • 原文地址:https://www.cnblogs.com/platero/p/1870117.html
Copyright © 2011-2022 走看看