题解 | #炮台攻击#
炮台攻击
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; }