Keiichi Tsuchiya the Drift King (c++三角函数公式)【几何+三角函数公式】
Keiichi Tsuchiya the Drift King
感谢: https://blog.csdn.net/xiao_you_you/article/details/89357815
题目链接(点击)
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 aa inches and of length bb inches. He makes a right turn of a curve whose internal boundary is an arc with dd degrees in a circle with a radius of rr 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 ww 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 TT indicating the number of test cases which is up to 104104.
For each test case, the only one line contains four integers aa, bb, rr and dd, where 0<a,b,r<1000<a,b,r<100 and 0<d<1800<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−610−6. Precisely speaking, assuming that your answer is aa and the jury's answer is bb, your answer will be considered correct if |a−b|max{1,|b|}≤10−6|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
思路:
上面链接讲解的很清楚 给出用到的一些公式:
1、度数与弧度关系:
1° = π/180 (弧度)
1 (弧度) = 180/π °
2、反三角函数公式:
sin (A) = a --> A = asin (a)
cos (A) = a --> A = acos (a)
tan (A) = a --> A = atan (a)
3、π = acos (-1) 或 π = 2 * asin(1)
(挺方便的不需要有意的精确到几位数)
AC代码:
#include<stdio.h>
#include<math.h>
using namespace std;
const double PI=acos(-1);
int main()
{
int T;
scanf("%d",&T);
while(T--){
double a,b,r,d;
scanf("%lf%lf%lf%lf",&a,&b,&r,&d);
double maxx=sqrt(b*b+(a+r)*(a+r));
double ap=atan((double)b/(a+r));
d=d*(PI/180.0);
if(d>ap){
printf("%.12lf\n",maxx-r);
}
else{
double a1=ap-d;
double w=cos((double)a1)*maxx-r;
printf("%.12lf\n",w);
}
}
return 0;
}
Keiichi Tsuchiya the Drift King (c++三角函数公式)【几何+三角函数公式】的更多相关文章
- 2018 ICPC 区域赛 焦作场 D. Keiichi Tsuchiya the Drift King(计算几何)
http://codeforces.com/gym/102028/problem/D 题意:根据题中给的那个图,然后题目给你 a,b,r,d,让你求出最小的满足矩形通过弯道的w 思路:
- D - Keiichi Tsuchiya the Drift King Gym - 102028D (几何)
题目链接:https://cn.vjudge.net/contest/275150#problem/D 题目大意: 问你能满足那个矩形可以顺利通过的条件,然后求出最小的w 具体思路:首先,我们应该将情 ...
- 2018ICPC焦作 D-Keiichi Tsuchiya the Drift King /// 几何
题目大意: https://nanti.jisuanke.com/t/34142 有一个弯道抽象成圆的一部分 车子抽象成矩形 漂移过程中矩形上边会与圆的圆心在同一条直线上 以右上点贴着弯道边缘进行漂移 ...
- EXCEL 如何实现下拉填充公式,保持公式部分内容不变,使用绝对引用
EXCEL 如何实现下拉填充公式,保持公式部分内容不变,使用绝对引用 在不想变的单元格前加$符号(列标和列数,两个都要加$),变成绝对引用,默认情况是相对引用 L4固定不变的方式:$L$4 M4固定不 ...
- latex:在公式之中和公式之间插入说明文字和标点符号
在公式之中和公式之间插入说明文字和标点符号,主要使用 \intertext{文本} \shortintertext{文本} \text{文本} 这三个命令 代码: \begin{align*}x^{2 ...
- 简单几何(推公式) UVA 11646 Athletics Track
题目传送门 题意:给了长宽比例,操场一圈400米,问原来长宽的长度 分析:推出公式 /************************************************ * Author ...
- POI单元格添加公式以及读取公式结果的值
POI提供了为单元格添加条件样式的方法,但是我并没有找到获取单元格改变后样式的方法,获取到样式依旧是没有改变之前的. 比如为单元格添加条件样式用于监听单元格值是否被修改,如果单元格值被修改那么字体颜色 ...
- 个人整理方幂和公式(∑i^k 公式)
有个Oier小学妹问了我一个Σi^k,i<=1e8 ,k<=1e6的问题,我认为这个用伯努利数列可能可以解决他的问题,所以整理了以下文章,给学弟学习学习~~~本人水平有限,也只能帮到这里了 ...
- latex之行内公式与行间公式
1.行内公式 我是对行内公式的测试$f(x)=1+x+x^2$ 2.行间公式 单行不编号 \begin{equation} \int_0^1(1+x)dx \end{equation} 结果为: 单行 ...
随机推荐
- Verilog代码和FPGA硬件的映射关系(二)
大家可能会有这样的疑问,我们编写的Verilog代码最终会在FPGA上以怎样的映射关系来实现功能呢?我们以一个最简单的组合逻辑与门为例来向大家说明.RTL代码如下所示: //------------- ...
- Java高级特性之集合
Java集合框架 一.Java集合框架概述 1.数组与集合的区别: 1)数组长度不可变化而且无法保存具有映射关系的数据:集合类用于保存数量不确定的数据,以及保存具有映射关系的数据. 2)数组元素既可以 ...
- [wordpress使用]003_添加新文章
当WordPress前面的工作准备的差不多,没什么大问题时,就可以开始为你的博客添加文章,让博客的内容变得更加丰富.既然你已经开始了这个博客,那么就说明你已经有一个明确的方向,知道自己到底要写那些内容 ...
- 50个SQL语句(MySQL版) 问题十四
--------------------------表结构-------------------------- student(StuId,StuName,StuAge,StuSex) 学生表 tea ...
- 【asp.net core 系列】2 控制器与路由的恩怨情仇
0. 前言 在上一篇文章中,我们初步介绍了asp.net core,以及如何创建一个mvc项目.从这一篇开始,我将为大家展示asp.net core 的各种内容,并且尝试带领大家来挖掘其中的内在逻辑. ...
- 【Java8新特性】重复注解与类型注解,你真的学会了吗?
写在前面 在Java8之前,在某个类或者方法,字段或者参数上标注注解时,同一个注解只能标注一次.但是在Java8中,新增了重复注解和类型注解,也就是说,从Java8开始,支持在某个类或者方法,字段或者 ...
- Java实现 LeetCode 720 词典中最长的单词(字典树)
720. 词典中最长的单词 给出一个字符串数组words组成的一本英语词典.从中找出最长的一个单词,该单词是由words词典中其他单词逐步添加一个字母组成.若其中有多个可行的答案,则返回答案中字典序最 ...
- Java实现 蓝桥杯VIP 算法提高 字符串比较
算法提高 字符串比较 时间限制:1.0s 内存限制:512.0MB 独立实现标准字符串库的strcmp函数,即字符串比较函数,从键盘输入两个字符串,按字典序比较大小,前者大于后者输出1,前者小于后者输 ...
- Java实现 LeetCode 92 反转链表 II
92. 反转链表 II 反转从位置 m 到 n 的链表.请使用一趟扫描完成反转. 说明: 1 ≤ m ≤ n ≤ 链表长度. 示例: 输入: 1->2->3->4->5-> ...
- Java实现蓝桥杯二项式的系数规律
二项式的系数规律,我国数学家很早就发现了. 如[图1.png],我国南宋数学家杨辉1261年所著的<详解九章算法>一书里就出现了. 其排列规律: 1 1 1 2 1 3 3 1 4 6 4 ...