ACM-ICPC 长沙现场赛 C 题 ZOJ3728(为什么我A过的数学题都是水题T_T)
2013-12-01 14:19
357 查看
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
medal Rm, 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.
one line. Here 1 ≤ Rm < R ≤ 2000, 1 ≤ r ≤ 1000, R + r < |(x, y)| ≤ 20000, 1 ≤ |(vx, vy)| ≤ 100.
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
medal Rm, 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 inone 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
大意 就是用半径为r的硬币去碰Rm的金牌,问在R范围内的时长。
本体的重点有三:1,硬币的半径处理,我是直接加到了Rm和R的上,然后硬币就成了点。
2,情况讨论,用直线到原点距离分成三种
3,就是判断方向了,方向不对直接0
代码如下:
#pragma comment(linker, "/STACK:102400000,102400000") #include "iostream" #include "cstring" #include "algorithm" #include "cmath" #include "cstdio" #include "sstream" #include "queue" #include "vector" #include "string" #include "stack" #include "cstdlib" #include "deque" #include "fstream" #include "map" using namespace std; typedef long long LL; const int INF = 0x1fffffff; const int MAXN = 1000; #define eps 1e-14 const int mod = 100000007; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 double dis(int x,int y,int vx,int vy) { return (double)abs(vx*y-vy*x)/sqrt(vx*vx+vy*vy); } int main() { //freopen("in","r",stdin); //freopen("out","w",stdout); int Rm,R,r,x,y,vx,vy; while (scanf("%d%d%d%d%d%d%d",&Rm,&R,&r,&x,&y,&vx,&vy)!=EOF) { double dis0=sqrt(x*x+y*y); double y1=y+vy/1000.0; double x1=x+vx/1000.0; if (sqrt(x1*x1+y1*y1)>dis0) printf("0.000\n");//判断方向 else { double l=dis(x,y,vx,vy); double v=sqrt(vx*vx+vy*vy); //cout<<l<<endl; Rm+=r; R+=r; if (l>=R) printf("0.000\n");//第一种未经过 else { double s0=2*sqrt(R*R-l*l); if (l>=Rm) printf("%.3lf\n",s0/v);//第二种直接穿过 else { double s1=s0-2*sqrt(Rm*Rm-l*l);//第三种碰撞发生 printf("%.3lf\n",s1/v); } } } } }
相关文章推荐
- HDU 4572 Bottles Arrangement(数学推公式)——2013 ACM-ICPC长沙赛区全国邀请赛
- 2013 ACM/ICPC 长沙现场赛 A题 - Alice's Print Service (ZOJ 3726)
- HDU 4565 So Easy!(数学+矩阵快速幂)(2013 ACM-ICPC长沙赛区全国邀请赛)
- HDU 4810 Wall Painting(组合数学 + 位运算)——2013ACM/ICPC亚洲区南京站现场赛
- ZOJ 3657 The Little Girl who Picks Mushrooms 第37届ACM/ICPC长春赛区现场赛C题(水题)
- HDU5073 ACM-ICPC亚洲区域赛鞍山赛区现场赛D题 Galaxy 贪心+数学推导
- 2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)
- HDU 4565 -- So Easy! 数学 && 2013 ACM-ICPC 长沙赛区全国邀请赛 A题
- ZOJ 3732 2013 ACM/ICPC 长沙赛区现场赛G题 Graph Reconstruction (图论)
- 【数学期望】【2012 ACM/ICPC 成都赛区现场赛】【B.Candy】
- ZOJ3827 ACM-ICPC 2014 亚洲区域赛牡丹江现场赛I题 Information Entropy 水题
- 2014ACM/ICPC亚洲区域赛现场赛D和K题解题报告
- HDU 4793 Collision (解二元一次方程) -2013 ICPC长沙赛区现场赛
- 2014 ACM/ICPC 鞍山赛区现场赛 D&I 解题报告
- codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)
- HDU 5532 2015ACM-ICPC长春赛区现场赛F题
- HDU 5512 2015ACM-ICPC沈阳赛区现场赛D题
- 【数学期望】Candy, ACM/ICPC Chengdu 2012, UVa1639 【精度】
- 2013 ACM-ICPC 亚洲区域赛 成都现场赛I 解题报告
- 2015 ACM/ICPC 长春现场赛