[ZOJ3728] Collision && 暴力解方程
来源:互联网 发布:淘宝设置自动发货 编辑:程序博客网 时间:2024/05/16 08:54
设出时间t 解方程
#include<cstdio>#include<algorithm>#include<cstring>#include<vector>#include<cstring>#include<cmath>#define SF scanf#define PF printfusing namespace std;typedef long long LL;const double PI = acos(-1.0);struct Vector {int x, y;Vector() {}Vector(double xx, double yy) { x = xx; y = yy; }Vector(double rad) { x = cos(rad); y = sin(rad); }double len() const { return sqrt(x*x + y*y); }Vector operator + (const Vector &b) const {return Vector(x + b.x, y + b.y);}Vector operator - (const Vector &b) const {return Vector(x - b.x, y - b.y);}Vector operator * (const Vector &b) const {return Vector(x - b.x, y - b.y);}Vector operator * (const double &b) const {return Vector(x*b, y*b);}Vector operator / (const double &b) const {return Vector(x / b, y / b);}bool operator == (const Vector &b) const {return x == b.x && y == b.y;}};double Dot(const Vector &a, const Vector &b) {return a.x * b.x + a.y * b.y;}double Cross(const Vector &a, const Vector &b) {return a.x * b.y - a.y * b.x;}Vector GetAngle(const Vector &a, const Vector &b) {double l1 = a.len(), l2 = b.len();return Vector(Dot(a, b) / l1 / l2, Cross(a, b)/ l1 / l2);}// 逆时针旋转Vector Rotate(const Vector &a, const Vector &angle) {return Vector(a.x * angle.x - a.y * angle.y, a.x * angle.y + a.y * angle.x);}typedef Vector Point, Angle;int Rm, Rr, Rc;Point O(0, 0), Coin;Vector v;int main(){while(SF("%d%d%d%d%d%d%d", &Rm, &Rr, &Rc, &Coin.x, &Coin.y, &v.x, &v.y) == 7){double c = - (Rr + Rc) * (Rr + Rc) + Coin.x * Coin.x + Coin.y * Coin.y;double b = 2 * (Coin.x * v.x + Coin.y * v.y);double a = v.x * v.x + v.y * v.y;double delta = b * b - 4 * a * c;if(delta <= 0) {puts("0.000");continue;}double ans = 0;double tmp1 = (-b + sqrt(delta)) / 2 / a, tmp2 = (-b - sqrt(delta)) / 2 / a;if(tmp2 >= 0) {c = Coin.x * Coin.x + Coin.y * Coin.y - (Rm + Rc) * (Rm + Rc);delta = b * b - 4 * a * c;if(delta <= 0) {ans = tmp1 - tmp2;}else {double tmp = (-b - sqrt(delta)) / 2 / a;ans = (tmp - tmp2) * 2;}PF("%.3lf\n", ans);}else {puts("0.000");}}}
0 0
- [ZOJ3728] Collision && 暴力解方程
- ZOJ3728 Collision (计算几何,圆)
- HDU 4793 Collision --解方程
- UVALive 6613 Collision(物理解方程)
- HDU-4793 Collision 计算几何 解方程
- 138 - Street Numbers//暴力or解方程
- HDU 5514 Collision(扩展欧几里得+解方程)——2014ACM/ICPC亚洲区北京站
- hdu5114 Collision(一元同余方程)
- HDU 5114 Collision 拓展GCD方法和解方程都能解
- HDU 5114 Collision(一元线性同余方程)
- HDU 5114 Collision(一元线性同余方程)
- Collision
- 【暴力搜索】[POJ 1186]方程的解数
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- poj 1469 COURSES (二分图匹配)
- 写了一个基于微信公众平台的图片识别应用!
- Java中return的用法
- c语言输入输出的一些细节
- Summary - 2015.2.3 分治
- [ZOJ3728] Collision && 暴力解方程
- 求子数组的最大和
- 蓝桥杯-算法训练-ALGO2-最大最小公倍数
- struts2中jsp页面跳转问题
- 构造函数及有关函数的调用过程
- 正则表达式30分钟入门教程
- XML----DTD-操作,实体
- 关于在Struts2的Action中使用domain模型接收参数的问题
- colorbar的应用