题意:固定一个勋章,然后有一个大圆,用一个硬币从一个点发射,给定方向,可能与勋章产生动量守恒的碰撞。问与大圆相交的时间。
思路:解析几何搞一搞就出来了。首先判一下是否会碰到大圆,然后就用点到直线的距离和两个三角形辅助搞一搞。。图画一下就出来了。就是大三角形的直角边减去小三角形的直角边乘以二这样。好像可以写的更简洁一点不过反正都过了233
AC代码:
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const double eps = 1e-8;
int main()
{
double Rm, R, r, x, y, vx, vy, d, ans;
while (~scanf("%lf%lf%lf%lf%lf%lf%lf", &Rm, &R, &r, &x, &y, &vx, &vy))
{
d = abs(vx*y - vy*x) / sqrt(vx*vx + vy*vy);//点到直线距离
if (x*vx + y*vy > eps || d > R + r)//与大圆不相交
{
printf("%.03lf\n", 0.0);
continue;
}
ans = sqrt((R + r)*(R + r) - d*d);//大三角形的直角边
if (d > r + Rm)//如果没碰撞
{
ans = ans * 2.0;
ans = ans / sqrt(vx*vx + vy*vy);
printf("%.03lf\n", ans);
continue;
}
ans = ans - sqrt((Rm + r)*(Rm + r) - d*d);
ans = ans * 2.0;
ans = ans / sqrt(vx*vx + vy*vy);
printf("%.03lf\n", ans);
}
return 0;
}