2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)
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 (x, y) and initial speed vector (vx, vy) 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 Rm, R, r, x, y, vx and vy in one line. Here 1 ≤ Rm < R ≤ 2000, 1 ≤ r ≤ 1000, R + r < |(x, y)| ≤ 20000, 1 ≤ |(vx, vy)| ≤ 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)的更多相关文章
- 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 ...
- 2013 ACM/ICPC 长沙网络赛J题
题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字 ...
- hdu 4435 第37届ACM/ICPC天津现场赛E题
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题目:给出N个城市,从1开始需要遍历所有点,选择一 ...
- 2013 ACM/ICPC 长春网络赛E题
题意:给出一个字符串,要从头.尾和中间找出三个完全相等的子串,这些串覆盖的区间互相不能有重叠部分.头.尾的串即为整个字符串的前缀和后缀.问这个相同的子串的最大长度是多少. 分析:利用KMP算法中的ne ...
- 2013 ACM/ICPC 长春网络赛F题
题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...
- 2013 ACM/ICPC 南京网络赛F题
题意:给出一个4×4的点阵,连接相邻点可以构成一个九宫格,每个小格边长为1.从没有边的点阵开始,两人轮流向点阵中加边,如果加入的边构成了新的边长为1的小正方形,则加边的人得分.构成几个得几分,最终完成 ...
- 2013 ACM/ICPC 杭州网络赛C题
题意:驴和老虎,在一个矩阵的两个格子里,有各自的起始方向.两者以相同的速度向前移动,前方不能走时驴总是向右,老虎总是向左.他们不能超出矩阵边界也不能走自己走过的格子(但可以走对方走过的格子).如果不能 ...
- hdu 4432 第37届ACM/ICPC天津现场赛B题
题目大意就是找出n的约数,然后把约数在m进制下展开,各个数位的每一位平方求和,然后按m进制输出. 模拟即可 #include<cstdio> #include<iostream> ...
- HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题
第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...
随机推荐
- linux内核-红黑树
//rbtree.h /* Red Black Trees (C) 1999 Andrea Arcangeli <andrea@suse.de> This program ...
- Python:itertools模块
itertools模块包含创建有效迭代器的函数,可以用各种方式对数据进行循环操作,此模块中的所有函数返回的迭代器都可以与for循环语句以及其他包含迭代器(如生成器和生成器表达式)的函数联合使用. ch ...
- uva 11107 Life Forms
题意:给你N个串,求一个串在大于等于N/2的模板串中连续出现.如果有多解按字典序最小输出. 白书模板题.二分答案+合并模板串成一个新串,扫秒新串的height数组. 考查后缀数组+LCP #inclu ...
- 【Hadoop学习】CDH5.2安装部署
[时间]2014年11月19日 [平台]Centos 6.5 [工具]scp [软件]jdk-7u67-linux-x64.rpm CDH5.2.0-hadoop2.5.0 [步骤] 1. 准备条件 ...
- 问题-关于SizeOf在Delphi7和Delphi2009下结果分别是16/32
问题:同样的代码在Delphi7和Delphi2009下结果分别是16/32,为什么?var LWindCode : array [0..15] of char; begin showmess ...
- 用 C# 做人脸检测(EmguCV)
用 C# 做人脸检测(EmguCV) 原发:bbs.csdn.net 作者:野比 (conmajia@gmail.com) 时间:May 2012 下载源码 准备工作 下载 EmguCV 傻瓜安装 ...
- 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum
package homework003; import java.util.ArrayList; import java.util.List; public class Text { public s ...
- cocos2d_随手篇1_关于ccTouchBegan的调用
在新的cocos框架里,旧的调用ccTouchBegan方法被和谐掉了!so! 直接来代码 1 -(void)doSometing{ 2 [[[CCDirector sharedDirector] ...
- 对PostgreSQL xmax的理解
xmax The identity (transaction ID) of the deleting transaction, or zero for an undeleted row version ...
- HDU 5289 Assignment(2015 多校第一场二分 + RMQ)
Assignment Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...