题解 | #炮台攻击#

炮台攻击

http://www.nowcoder.com/practice/f821a39207cd43518ccddb27fee0481d

#include<stdio.h>
#include<math.h>
int main()
{
    int r, x1, y1, x2, y2, x3, y3, x0, y0;
    while(scanf("%d %d %d %d %d %d %d %d %d", &r, &x1, &y1, &x2, &y2, &x3, &y3, &x0, &y0) != EOF)
    {
        double d[3];
        d[0] = pow((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0), 0.5);
        d[1] = pow((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0), 0.5);
        d[2] = pow((x3-x0)*(x3-x0)+(y3-y0)*(y3-y0), 0.5);
        int count = 0;
        for(int i=0; i<3; i++)
        {
            if(d[i] <= r)    count++;
        }
        printf("%dx\n", count);
    }
    return 0;
}
全部评论

相关推荐

牛客963010790号:为什么还要收藏
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务