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/16922749 AC代码:
 #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、精确度问题:三位小数;

2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)的更多相关文章

  1. 2013 ACM/ICPC 长沙现场赛 A题 - Alice's Print Service (ZOJ 3726)

    Alice's Print Service Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is providing print ser ...

  2. 2013 ACM/ICPC 长沙网络赛J题

    题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字 ...

  3. hdu 4435 第37届ACM/ICPC天津现场赛E题

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题目:给出N个城市,从1开始需要遍历所有点,选择一 ...

  4. 2013 ACM/ICPC 长春网络赛E题

    题意:给出一个字符串,要从头.尾和中间找出三个完全相等的子串,这些串覆盖的区间互相不能有重叠部分.头.尾的串即为整个字符串的前缀和后缀.问这个相同的子串的最大长度是多少. 分析:利用KMP算法中的ne ...

  5. 2013 ACM/ICPC 长春网络赛F题

    题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...

  6. 2013 ACM/ICPC 南京网络赛F题

    题意:给出一个4×4的点阵,连接相邻点可以构成一个九宫格,每个小格边长为1.从没有边的点阵开始,两人轮流向点阵中加边,如果加入的边构成了新的边长为1的小正方形,则加边的人得分.构成几个得几分,最终完成 ...

  7. 2013 ACM/ICPC 杭州网络赛C题

    题意:驴和老虎,在一个矩阵的两个格子里,有各自的起始方向.两者以相同的速度向前移动,前方不能走时驴总是向右,老虎总是向左.他们不能超出矩阵边界也不能走自己走过的格子(但可以走对方走过的格子).如果不能 ...

  8. hdu 4432 第37届ACM/ICPC天津现场赛B题

    题目大意就是找出n的约数,然后把约数在m进制下展开,各个数位的每一位平方求和,然后按m进制输出. 模拟即可 #include<cstdio> #include<iostream> ...

  9. HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题

    第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...

随机推荐

  1. 【DOM】2.闭包

    1.什么是闭包? 函数嵌套函数 内部函数可以引用外部函数的参数和变量 参数和变量不会被JS中的垃圾回收机制 所收回 2.闭包有啥好处?应用在哪? ①希望一个变量长期驻扎在内存中 ②避免全局变量的污染 ...

  2. Node.js也分裂了-开源社区动态

    继CoreOS与Docker分道扬镳继而推出自己的容器引擎Rocket后不久,又传来了Node.js分裂的消息.由于Node.js的贡献者因对负责Node.js开发的公司Joyent在对Node.js ...

  3. MapReduce 支持的部分数据挖掘算法

    MapReduce 支持的部分数据挖掘算法 MapReduce 能够解决的问题有一个共同特点:任务可以被分解为多个子问题,且这些子问题相对独立,彼此之间不会有牵制,待并行处理完这些子问题后,任务便被解 ...

  4. 2.1CUDA-Thread

    在HOST端我们会分配block的dimension, grid的dimension.但是对应到实际的硬件是如何执行这些硬件的呢? 如下图: lanuch kernel 执行一个grid. 一个Gri ...

  5. nginx变量

    nginx的全局变量参数解释: $arg_PARAMETER#这个变量包含GET请求中,如果有变量PARAMETER时的值. $args   #这个变量等于请求行中(GET请求)的参数,例如foo=1 ...

  6. 转载Entity Framework全面教程

    转载原地址:http://www.cnblogs.com/lsxqw2004/archive/2009/05/31/1495240.html#_Toc228672754 预备知识    2 LINQ技 ...

  7. Qt Creator编辑器乱问题

    新安装的Qt Creator 打开原来的工程源码时提示:无法用 "UTF-8"-编码解码 "main.cpp". 无法编辑   解决办法:修改项目属性的编辑器设 ...

  8. 图形用户界面(graphical user interface)

    1 java中提供的类库 1.1 定义 AWT(abstract windows toolkit)抽象窗口工具包:提供了与本地图形界面进行交互的接口,AWT中提供的图形函数与操作系统的图形函数有着对应 ...

  9. jdbc连接的工具类

    在不实用框架的情况下,有一个jdbc的工具类来进行数据库的连接就再好不过了,下面提供这个工具类DBUtil.java package org.jdbc.test; import java.io.Inp ...

  10. Python Telnet弱口令爆破脚本及遇到的错误与问题

    写得时候遇到了一个很大的问题,就是我在发送用户名,接受用户名就会一直卡住.然后等了好久后提示 recv ‘\r\nSession timed out.\r\n\r\nTelnet Server has ...