The 2013 ACM-ICPC Asia Changsha Regional Contest C Zoj Collision

本文探讨了一个圆形硬币在理想平面上滑动并可能与固定圆徽章碰撞的问题。通过分析硬币的不同运动路径,给出了硬币在指定区域内停留时间的计算方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 coinr, 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

Author: FAN, Yuzhe
Contest: The 2013 ACM-ICPC Asia Changsha Regional Contest
Submit    Status


题意:就是给一个圆台和圆台中央有一个固定的圆徽章,然后用一个圆形的硬币从外面以一条直线射进来,如果碰到到徽章就反弹,问你这个硬币在圆台中滑行的时间。。

思路:第一次做正式比赛的几何题。。。这道题可以分成三种情况,一,没有进入圆台所以是0,二,进入了耽美碰到徽章。三,进入了碰到徽章。。

现在主要讨论二三种情况。。看图:

第二种情况:

所以由图可知道距离为  sqrt((R+ r)*R+ r)-(点到直线的距离的平方))*2。。。

第三种情况:

则距离为:sqrt((R+r)^2-(原点到直线的距离)^2)-sqrt((Rm+r)^2-(原点到直线的距离)^2)....

在杭电上提交的同学请注意了。好像杭电上是没有特殊判断所以要保留3位小数。。不然会wa!!!

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
int rm,R,r,x,y,vx,vy;
double k,b;
double Dkb()
{
	if(vx==0)
		return (double)abs(x);
	if(vy==0)
		return (double)abs(y);
	double k = vy/(double)vx;
	double b = (double)y - k*x;
	return fabs((double)b)/(sqrt(k*k+1));

}
int main()
{
	while(~scanf("%d",&rm))
	{
		scanf("%d%d%d%d",&R,&r,&x,&y);
		scanf("%d%d",&vx,&vy);
		if(x*vx+y*vy>=0)
		{
			printf("0.0000\n");
			continue;
		}
		double h = Dkb();
		if(h>=R+r)
		{
			printf("0.0000\n");
			continue;
		}
		double V = sqrt(vx*vx+vy*vy),ans;
		if(h>=rm+r)
		{
			ans = 2*sqrt((R+r)*(R+r)-h*h);
			printf("%0.3f\n",ans/V);
		}
		else
		{
			ans = sqrt((R+r)*(R+r)-h*h);
			ans = ans - sqrt((rm+r)*(rm+r)-h*h);
			ans*=2.0;
			printf("%0.3f\n",ans/V);
		}
	}
	return 0;
}

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值