首页 技术 正文
技术 2022年11月14日
0 收藏 333 点赞 3,866 浏览 2323 个字

Collision


Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge


There’s a round medal fixed on an ideal smooth table, Fancy is trying to throw some coins and make them slip towards the medal to collide. There’s also a round range which shares exact the same center as the round medal, and radius of the medal is strictly less than radius of the round range. Since that the round medal is fixed and the coin is a piece of solid metal, we can assume that energy of the coin will not lose, the coin will collide and then moving as reflect.

Now assume that the center of the round medal and the round range is origin ( Namely (0, 0) ) and the coin’s initial position is strictly outside the round range. Given radius of the medalRm, radius of coin r, radius of the round range R, initial position (xy) and initial speed vector (vxvy) of the coin, please calculate the total time that any part of the coin is inside the round range.

Please note that the coin might not even touch the medal or slip through the round range.

Input

There will be several test cases. Each test case contains 7 integers RmRrxyvx and vy in one line. Here 1 ≤ Rm < R ≤ 2000, 1 ≤ r ≤ 1000, R + r < |(xy)| ≤ 20000, 1 ≤ |(vxvy)| ≤ 100.

Output

For each test case, please calculate the total time that any part of the coin is inside the round range. Please output the time in one line, an absolute error not more than 1e-3 is acceptable.

Sample Input

5 20 1 0 100 0 -1
5 20 1 30 15 -1 0

Sample Output

30.000
29.394题意:http://blog.csdn.net/night_raven/article/details/16922749AC代码:
 #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <iomanip>
using namespace std;
#define INF 0x7fffffff
#define maxn 1010
#define eps 1e-12
const double PI = acos(-1.0);
typedef unsigned long long ull; double Rm, R, r, x, y, vx, vy; double dis(double k, double b)
{
return fabs(b) / sqrt(k*k + );
} int main()
{
//freopen("out.txt", "w", stdout);
while(~scanf("%lf%lf%lf%lf%lf%lf%lf", &Rm, &R, &r, &x, &y, &vx, &vy))
{
if(x*vx + y*vy >= ) //相反方向移动!
{
printf("0.000\n");
continue;
}
double k, b, d1;
if(vx) {
k = vy / vx;
b = y - k*x;
d1 = dis(k, b);//运动轨迹与圆心距离
}
else d1 = fabs(x);
if(d1 >= R+r) {
printf("0.000\n");
continue;
} double v = sqrt(vx*vx + vy*vy); if(d1 >= Rm+r)//不会碰撞medal
double len = *sqrt((R+r)*(R+r) - d1*d1);
else
double len = *(sqrt((R+r)*(R+r) - d1*d1) - sqrt((Rm+r)*(Rm+r) - d1*d1));
printf("%.3lf\n", len / v);
}
return ;
}

注意:

1、判断运动方向是否是朝向圆心的方向:x*vx + y*vy < 0;

2、判断运动轨迹是否会进入圆形区域:dis >= R+r;

3、判断是否会与medal碰撞:dis < Rm+r;

4、精确度问题:三位小数;

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,020
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,359
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,142
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,772
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,850