题意:给一个圆和圆外两点A、B,在A以给定的速度(方向)出发,若碰到圆则发生完全弹性碰撞,问能否经过B。
题解:把b点对称过去,判断与a点斜率是否等于v,然后考虑一些特殊情况,比如射线交不到圆,经过b点再交圆等,最后ok函数要写好。。。
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define L(i) i<<1
#define R(i) i<<1|1
#define INF 0x3f3f3f3f
#define pi acos(-1.0)
#define eps 1e-9
#define maxn 200010
#define MOD 1000000007
int n,k;
struct Point
{
double x, y;
Point( double x = 0, double y = 0 ):x(x), y(y) { }
}a,b,st;
typedef Point Vector;
Vector v,vv;
struct Circle
{
Point c;
double r;
Circle(){}
Circle(Point c,double r):c(c),r(r){}
Point point(double a)
{
return Point(c.x + cos(a)*r,c.y + sin(a)*r);
}
}c;
struct Line
{
Point p;
Vector v;
double ang;
Line(){}
Line(Point p,Vector v):p(p),v(v)
{
ang = atan2(v.y,v.x);
}
Point point(double t)
{
return Point(p.x+v.x*t,p.y+v.y*t);
}
bool operator < (const Line& L) const
{
return ang < L.ang;
}
};
Vector operator+( Vector A, Vector B ) //向量加
{
return Vector( A.x + B.x, A.y + B.y );
}
Vector operator-( Vector A, Vector B ) //向量减
{
return Vector( A.x - B.x, A.y - B.y );
}
Vector operator*( Vector A, double p ) //向量数乘
{
return Vector( A.x * p, A.y * p );
}
Vector operator/( Vector A, double p ) //向量数除
{
return Vector( A.x / p, A.y / p );
}
bool operator<( const Point& A, const Point& B ) //两点比较
{
return A.x < B.x || ( A.x == B.x && A.y < B.y );
}
int dcmp( double x ) //控制精度
{
if ( fabs(x) < eps )
return 0;
else
return x < 0 ? -1 : 1;
}
bool operator==( const Point& a, const Point& b ) //两点相等
{
return dcmp( a.x - b.x ) == 0 && dcmp( a.y - b.y ) == 0;
}
double Dot( Vector A, Vector B ) //向量点乘
{
return A.x * B.x + A.y * B.y;
}
double Length( Vector A ) //向量模
{
return sqrt( Dot( A, A ) );
}
double Angle( Vector A,