题目链接:http://cstest.scu.edu.cn/soj/problem.action?id=4280
简单的计算几何吧,但我还是想了半天,求出点到圆的两条切线夹角,然后除以平均角度即为答案。
#include <stdio.h>
#include <math.h>
const double PI = acos(-1);
struct point
{
double x;
double y;
}p1, p2;
int s[4] = {0, 80, 120, 160};
double dis(double x1, double y1, double x2, double y2)
{
return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}
int main()
{
int t, n, l;
double x1, y1, x2, y2, r;
scanf("%d", &t);
while (t--)
{
scanf("%d%d%lf%lf%lf%lf%lf", &n, &l, &x1, &y1, &x2, &y2, &r);
if (n == 0)
{
puts("0");
continue;
}
double totalangle = 2.0 * asin(r/dis(x1, y1, x2, y2))/PI*180;
double ave = 360.0 / n;
int ans = 1 + int(totalangle / ave);
ans = ans * s[l];
printf("%d\n", ans);
}
}