2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest D.Keiichi Tsuchiya the Drift King(几何)

本文主要是介绍2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest D.Keiichi Tsuchiya the Drift King(几何),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目链接:https://codeforc.es/gym/102028/problem/D

Drifting is a driving style in which the driver uses the throttle, brakes, clutch, gear shifting and steering input to keep the car in a state of oversteer while manoeuvring from turn to turn. As a sport, the drifting was first practised in Japan in the late 80s before gaining worldwide popularity in the decade that followed.

Keiichi Tsuchiya is a Japanese driver who is better known as the Drift King. He played an important role in popularizing the art of drifting. This pioneer inspired many successful drivers. He appeared in the movie The Fast and the Furious: Tokyo Drift and he is often employed on various movie sets as both driver and stunt coordinator. Keiichi Tsuchiya’s talent in the drifting is especially true of his big stunt, the ultimate drifting.

Here is what he could do. The drift car he drives is shaped like a rectangular box of width a inches and of length b inches. He makes a right turn of a curve whose internal boundary is an arc with d degrees in a circle with a radius of r inches. As a super-skilled driver, he maintains his car to keep the contact and tangency at the internal boundary. That is, the right front corner of the car should always run along the internal boundary and the direction of the car body should always be tangential to the internal boundary.
在这里插入图片描述

We have measured that the straightaways before and after the curve are long enough, and the width of the lane is invariable. As what we meet in real life, if a lane has a fixed width, for each point of its one side, the distance to the nearest point of the other side is exactly its width. Now you are asked to calculate the minimal width w of the lane so that the Drift King could drive throughout the curve without drifting out of the lane.

Input
The input contains several test cases, and the first line contains a positive integer T indicating the number of test cases which is up to 104.

For each test case, the only one line contains four integers a, b, r and d, where 0<a,b,r<100 and 0<d<180.

Output
For each test case, output a line containing the minimal width (in inches) of the lane with an absolute or relative error of at most 10−6. Precisely speaking, assuming that your answer is a and the jury’s answer is b, your answer will be considered correct if |a−b|max{1,|b|}≤10−6.

Example

input

4
1 2 2 120
1 2 2 60
1 2 2 30
1 2 2 15

output

1.605551275464
1.605551275464
1.598076211353
1.415415569072

题意

漂移王要顺利飘逸过弯,车的一边始终与弯道相切,在过程中车身不能再路面以外,求路宽度最小是多少。

分析

一道几何体,我们设车的左下角为 X ,圆心 O 与 X 相连,发现如果 OX 在弯道的圆弧范围内,那么最窄至少要 sqrt((a + r) * (a + r) + b * b) - r (可以直接用勾股定律算出);如果在圆弧范围外的话,我们可以用相似三角形推出最小宽度。

代码
#include<bits/stdc++.h>
using namespace std;int t;
double a,b,r,d;int main()
{//printf("%.10lf",tan(3.1415 / 6.0));scanf("%d",&t);while(t--){scanf("%lf%lf%lf%lf",&a,&b,&r,&d);double D = d;d = d / 180.0 * 3.1415926;double temp = sqrt((a + r) * (a + r) + b * b) - r;double ans = temp;if(D < 90 && tan(d) < b / (a + r)){double x1 = tan(d) * (a + r);double y2 = b - x1;double y1 = sqrt((a + r) * (a + r) + x1 * x1);double x2 = y2 * sin(d);double temp2 = y1 + x2 - r;if(temp2 > 0) ans = min(ans, temp2);}printf("%.12lf\n",ans);}return 0;
}

这篇关于2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest D.Keiichi Tsuchiya the Drift King(几何)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/305487

相关文章

认识、理解、分类——acm之搜索

普通搜索方法有两种:1、广度优先搜索;2、深度优先搜索; 更多搜索方法: 3、双向广度优先搜索; 4、启发式搜索(包括A*算法等); 搜索通常会用到的知识点:状态压缩(位压缩,利用hash思想压缩)。

uva 10387 Billiard(简单几何)

题意是一个球从矩形的中点出发,告诉你小球与矩形两条边的碰撞次数与小球回到原点的时间,求小球出发时的角度和小球的速度。 简单的几何问题,小球每与竖边碰撞一次,向右扩展一个相同的矩形;每与横边碰撞一次,向上扩展一个相同的矩形。 可以发现,扩展矩形的路径和在当前矩形中的每一段路径相同,当小球回到出发点时,一条直线的路径刚好经过最后一个扩展矩形的中心点。 最后扩展的路径和横边竖边恰好组成一个直

poj 1113 凸包+简单几何计算

题意: 给N个平面上的点,现在要在离点外L米处建城墙,使得城墙把所有点都包含进去且城墙的长度最短。 解析: 韬哥出的某次训练赛上A出的第一道计算几何,算是大水题吧。 用convexhull算法把凸包求出来,然后加加减减就A了。 计算见下图: 好久没玩画图了啊好开心。 代码: #include <iostream>#include <cstdio>#inclu

uva 1342 欧拉定理(计算几何模板)

题意: 给几个点,把这几个点用直线连起来,求这些直线把平面分成了几个。 解析: 欧拉定理: 顶点数 + 面数 - 边数= 2。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#inc

XTU 1237 计算几何

题面: Magic Triangle Problem Description: Huangriq is a respectful acmer in ACM team of XTU because he brought the best place in regional contest in history of XTU. Huangriq works in a big compa

BUUCTF靶场[web][极客大挑战 2019]Http、[HCTF 2018]admin

目录   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 [web][HCTF 2018]admin 考点:弱密码字典爆破 四种方法:   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 访问环境 老规矩,我们先查看源代码

poj 3304 几何

题目大意:给出n条线段两个端点的坐标,问所有线段投影到一条直线上,如果这些所有投影至少相交于一点就输出Yes!,否则输出No!。 解题思路:如果存在这样的直线,过投影相交点(或投影相交区域中的点)作直线的垂线,该垂线(也是直线)必定与每条线段相交,问题转化为问是否存在一条直线和所有线段相交。 若存在一条直线与所有线段相交,此时该直线必定经过这些线段的某两个端点,所以枚举任意两个端点即可。

POJ 2318 几何 POJ 2398

给出0 , 1 , 2 ... n 个盒子, 和m个点, 统计每个盒子里面的点的个数。 const double eps = 1e-10 ;double add(double x , double y){if(fabs(x+y) < eps*(fabs(x) + fabs(y))) return 0 ;return x + y ;}struct Point{double x , y

poj 2653 几何

按顺序给一系列的线段,问最终哪些线段处在顶端(俯视图是完整的)。 const double eps = 1e-10 ;double add(double x , double y){if(fabs(x+y) < eps*(fabs(x) + fabs(y))) return 0 ;return x + y ;}struct Point{double x , y ;Point(){}Po

2014 Multi-University Training Contest 8小记

1002 计算几何 最大的速度才可能拥有无限的面积。 最大的速度的点 求凸包, 凸包上的点( 注意不是端点 ) 才拥有无限的面积 注意 :  凸包上如果有重点则不满足。 另外最大的速度为0也不行的。 int cmp(double x){if(fabs(x) < 1e-8) return 0 ;if(x > 0) return 1 ;return -1 ;}struct poin