THE TOWER【纯数学】

2023-11-03 20:30
文章标签 tower 纯数学

本文主要是介绍THE TOWER【纯数学】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目链接:http://icpc.upc.edu.cn/problem.php?cid=1747&pid=4

题目描述

The Tower shows atall tower perched on the top of a rocky mountain. Lightning strikes, setting the building alight, and two people leap frnm the windows, head first and arms outstretched.
It is a scene of chaos and destruction.
There is a cone tower with base center at (0, 0, 0), base radius r and apex (0, 0, h) . At time 0 , a point located at ( x0 ,y0, z0) with velocity (vx,vy,vz). What time will they collide? Here is the cone tower.
在这里插入图片描述
输入
The first line contains testcase number T (T≤1000), For each testcase the first line contains spaceseparated real numbers rand h (1≤r,h≤1000) the base radius and the cone height correspondingly.
For each testcase the second line contains three real numbers x0 ,y0, z0 (0≤|x0|,|y0|,z0≤1000). For each testcase the third line contains three real numbers vx,vy,vx (). It is guaranteed that at time 0 the point is outside the cone and they will always collide.
输出
For each testcase print Case i: and then print the answer in one line, with absolute or relative error not exceeding 10-6
样例输入
2
1 2
1 1 1
-1.5 -1.5 -0.5
1 1
1 1 1
-1 -1 -1
样例输出
Case 1: 0.3855293381
Case 2: 0.5857864376

解题思路

解方程组
{ x = x 0 + v 1 t y = y 0 + v 2 t z = z 0 + v 3 t x 2 + y 2 r 2 = ( h − z ) 2 h 2 \begin{cases} x=x_{0}+v_{1}t\\ y=y_{0}+v_{2}t\\ z=z_{0}+v_{3}t\\\frac{x^{2}+y^{2}}{r^{2}}=\frac{(h-z)^{2}}{h^{2}}\\ \end{cases} x=x0+v1ty=y0+v2tz=z0+v3tr2x2+y2=h2(hz)2
t t t即为需要的时间

AC代码

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define io ios::sync_with_stdio(0),cin.tie(0)
#define ms(arr) memset(arr,0,sizeof(arr))
#define mc(a,b) memcpy(a,b,sizeof(b))
#define inf 0x3f3f3f
#define fin freopen("in.txt", "r", stdin)
#define fout freopen("out.txt", "w", stdout)
typedef long long ll;
typedef unsigned long long ULL;
const int mod=1e9+7;
const int N=1e5+7;int main()
{
//    fin;int t;double r,h,x,y,z,v1,v2,v3;scanf("%d",&t);for(int k=1;k<=t;k++){scanf("%lf %lf",&r,&h);scanf("%lf %lf %lf",&x,&y,&z);scanf("%lf %lf %lf",&v1,&v2,&v3);double a=h*h*v1*v1+h*h*v2*v2-r*r*v3*v3;double b=2.0*h*h*x*v1+2.0*h*h*y*v2+2.0*r*r*h*v3-2.0*r*r*z*v3;double c=2.0*r*r*z*h-r*r*h*h-r*r*z*z+h*h*x*x+h*h*y*y;double d=b*b-4.0*a*c;double ans=(-b-sqrt(d))/(2.0*a);printf("Case %d: %.10f\n",k,ans);}return 0;
}

这篇关于THE TOWER【纯数学】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

437 - The Tower of Babylon(动态规划)

这题感觉比较水了,只不过建立模型的时候需要想一下,给n个长方体,我们不妨给它长宽高固定的3个长方体。 之后根据长宽的大小排序。 dp[i]代表第i个长方体当顶面的时候的高度,所以初始的时候dp[i] = cub[i[.h, dp[i] = dp[j] + cub[i[.h(当j的长宽均严格小于i的时候成立) 13989891 437 The Tower of Babylon Acce

Tower for Mac Git客户端管理软件

Mac分享吧 文章目录 效果一、下载软件二、开始安装1、双击运行软件,将其从左侧拖入右侧文件夹中,等待安装完毕2、应用程序显示软件图标,表示安装成功 三、运行测试1、打开软件,测试2、克隆项目,测试 安装完成!!! 效果 一、下载软件 下载软件 链接:www.macfxb.cn 二、开始安装 1、双击运行软件,将其从左侧拖入右侧文件夹中,等待安装完毕

[HDU 5886] Tower Defence (树形DP)

HDU - 5886 给定一棵树,每条边都有一个权值 定义一条边的战术价值为割去这条边后 剩下的图中最长链的长度 求随机割掉一条边,战术价值的期望 题目要求乘以 N−1 N-1,所以直接把概率消掉了 所以只要求割去每条边后的最长链长度即可 这就转化为了一个树形dp 首先割去一条边 u−>v u->v 后,最长链可能在 v v 为根的子树中 这个简单地做一次树形dp

Ansible-Tower快速入门-1.概览【翻译】

概览 Tower Ansible-Tower是作为Ansible的一个web接口界面,并采用REST API作为端点接入。通过使用开源的orchestration engine,无论是与你的团队共享操作任务,或是通过REST API与你的Ansible集成,Tower都提供了许多强大的自动化工具来让你的生活更轻松。 实时的playbooks输出和浏览 可以实时的查看playbooks的

Codeforces 392B Tower of Hanoi(递归+记忆化搜索)

题目链接:Codeforces 392B Tower of Hanoi 题目大意:给出一个3*3的矩阵,表示从i移动到j的代价,现在给出n,表示有n个碟子在1柱,需要移动到3柱,要求给出最小的花费。 解题思路:dp[l][r][n],表示的是从l移动n个碟子到r的最小花费,然后总共有两种移动方式: ans1 = solve(l, x, n-1) + solve(x, r, n-1

HDU 4939 Stupid Tower Defense

题目链接~~> 做题感悟:开始看着题很明显的 dp 但是dp 到最后也没 dp 出来,做完这题之后发现其实有些 dp 需要一些贪心的思想,然后再dp一下。 解题思路:                    三种塔都有各自的功能,就和英雄杀里的人物技能一样,绿塔和蓝塔貌似为红塔做铺垫,绿塔负责增加伤害,蓝塔负责增加时间,和英雄杀里宋江,西施,商鞅三个人的配合差不多,只有相互配合才使得伤害最大化

Codeforces Round #230 (Div. 2) C. Blocked Points D. Tower of Hanoi

C. Blocked Points 题意:A点和B点是4-connected,的条件是 the Euclidean distance between A and B is one unit and neither A nor B is blocked; or there is some integral point C, such that A is 4-connected with C,

Tower在深度学习中的概念,tower没有确切定义

在论文UniTS中,来自Havard的工作。 tower更像是针对一个task的组件 tower这个概念貌似在REC(recommendation)推荐系统中使用较多 deep learning - What is a tower? - Data Science Stack Exchange  https://developers.google.com/machine-lea

Tower for Mac:Git管理的新境界

Tower for Mac,让您的Git管理进入新境界!这款专为Mac用户打造的Git客户端,凭借其出色的性能和丰富的功能,成为众多开发者的首选工具。 Tower不仅支持常规的Git操作,如提交、推送和拉取,还提供了许多高级功能,如分支比较、合并冲突解决等,让您能够更深入地管理代码版本。同时,它还支持多种团队协作方式,让您能够与团队成员无缝协作,共同推进项目进度。 在使用体验上,Tower fo

jenkins+gitlab+ansible-tower实现发布

前提准备: gitlab中上传相应的jenkinsfile文件和源码。 安装和破解ansible-tower。 安装jenkins。 大致流程:从gitlab中拉取文件,存放到windows机器上,使用nuget等进行打包到windows中,使用sshPublisher语句传输到远程ansible-tower的机器上,打包传输完成后,使用ansible-tower进行发布。 机器分布: jenki