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 ...
随机推荐
- Codeforces Round #359 (Div. 1)
A http://codeforces.com/contest/685/standings 题意:给你n和m,找出(a,b)的对数,其中a满足要求:0<=a<n,a的7进制的位数和n-1的 ...
- 【转】 bash简介及通配符、扩展通配符 shopt -s extglob
http://www.rhce.cc/?p=1005 当我们执行一些命令的时候,很多的命令是由bash提供的.如果我们想知道某个命令是否是由bash内置的命令的话,我们可以使用type bash内置命 ...
- Android 开发Project中各个目录和文件的介绍
如上图标号: 存放java文件的文件夹“src”: 由aapt工具根据应用中的资源文件自动生成的R.java文件,以及buildConfiger.java文件,这两个文件最好不要去修改: 存放各种资源 ...
- asp.net(C#) 中 怎么使用 MongoDb
1. 先引用以下Dll(如果找不到 到gethub上下载源代码自己编译 特别是MongoDB.Driver.Legacy.dll 我自己找了半天没找到): MongoDB.Bson.dll Mongo ...
- nyoj 115 城市平乱
城市平乱 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市. 他在用这N个部队维护着M个城市的治安,这M个城市 ...
- ios开发-确定/自适应textView的高度
昨天在做学院客户端的时候,随手clean了下项目. 不过xcode又闹脾气了,textview里面的字体大小居然在真机运行的时候普遍小了2号.. 这下蛋疼了.应该我项目里面textview的frame ...
- 用EPOLL进行压力测试
在以前的博客中提到的一个服务端,在以前压力测试的过程中,发现单核CPU最多能达到1000TPS 还以为是服务端性能不够好,所以一直想着怎么去优化它. 但优化的思路明显不多,所以就考虑换一种压力测试的方 ...
- 图形用户界面(graphical user interface)
1 java中提供的类库 1.1 定义 AWT(abstract windows toolkit)抽象窗口工具包:提供了与本地图形界面进行交互的接口,AWT中提供的图形函数与操作系统的图形函数有着对应 ...
- CentOS6.5安装MySQL及完全卸载
原文地址:http://www.cnblogs.com/zhongshengzhen/ 第1步.yum安装mysql [root@localhost ~]# yum -y install mysql- ...
- matlab inpolygon 判断点在多边形内
如何判断一个点在多边形内部? xv= [0 3 3 0 0]; %x坐标 yv= [0 0 3 3 0];%y坐标 x=1.5; y=1.5; in=inpolygon(x,y,xv,yv) plot ...