【基础数学知识】UVa 11314 - Hardly Hard
Problem H
HARDLY HARD
You have been given the task of cutting out a quadrilateral slice of cake out of a larger, rectangular cake. You must find the slice with the smallest perimeter that satisfies the following constraints. If the cake is of size 10000-by-10000 units and is represented using the first quadrant of the Cartesian plane, then your slice is quadrilateral ABCD (see figure). Points A and B are fixed and will be given to you. Also, A,B will lie on a negatively sloping line. Furthermore, points C and D must lie on the positive y-axis and positive x-axis respectively, but it is up to you to determine where these two points should be. A,B,C,D will be distinct points.
Output the minimum perimeter of your slice of cake.
Input
On the first line you will be given n (1 ≤ n ≤ 100), the number of test cases. The following n lines each contain ax ay bx by (0 < ax, ay, bx, by ≤ 10000.0), the coordinates of points A and B respectively.
Output
For each test case, output the perimeter accurate to 3 decimal places on its own line.
题意:由一个矩形蛋糕切出一个四边形,要求周长最小;其中A,B两点坐标已给出,且C,D点要求在x,y轴正半轴。
分析:以x,y轴作对称点连接。证明很好证,两点之间线段最短嘛。
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #define error 1e-8
- using namespace std;
- const int maxn = ;
- double Get_len(double x1, double y1, double x2, double y2)
- {
- return sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1));
- }
- int main()
- {
- int T;
- scanf("%d", &T);
- while(T--)
- {
- double ax, ay, bx, by;
- scanf("%lf%lf%lf%lf", &ax, &ay, &bx, &by);
- if(by < ay) {swap(ay, by); swap(ax, bx);}
- double cx=ax, cy=-ay, dx=-bx, dy=by;
- printf("%.3lf\n", Get_len(cx, cy, dx, dy)+Get_len(ax, ay, bx, by));
- }
- return ;
- }
【基础数学知识】UVa 11314 - Hardly Hard的更多相关文章
- Python之基础数学知识
一.线性代数 1.求转置 import numpy m = numpy.mat([[1, 2], [3, 4]]) print("Matrix.Transpose:") print ...
- 基础数学知识 / Math(updating)
埃氏筛:朴素筛法求素数,o(nloglogn) int prime[N], tot; bool st[N]; // true:not prime, false:is prime void get_pr ...
- HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识
一,canvas元素 1 为了防止浏览器不支持canvas元素,我们设置“后备内容”(fallback content),下面紫色的字即为后备内容 <canvas id="canvas ...
- HTML5中手势原理分析与数学知识的实践
摘要:在这触控屏的时代,人性化的手势操作已经深入了我们生活的每个部分.现代应用越来越重视与用户的交互及体验,手势是最直接且最为有效的交互方式,一个好的手势交互,能降低用户的使用成本和流程,大大提高了用 ...
- [web建站] 极客WEB大前端专家级开发工程师培训视频教程
极客WEB大前端专家级开发工程师培训视频教程 教程下载地址: http://www.fu83.cn/thread-355-1-1.html 课程目录:1.走进前端工程师的世界HTML51.HTML5 ...
- 用CSS变形创建圆形导航
http://www.w3cplus.com/css3/building-a-circular-navigation-with-css-transforms.html 本文由陈毅根据SARA SOUE ...
- 机器学习的数学基础(1)--Dirichlet分布
机器学习的数学基础(1)--Dirichlet分布 这一系列(机器学习的数学基础)主要包括目前学习过程中回过头复习的基础数学知识的总结. 基础知识:conjugate priors共轭先验 共轭先验是 ...
- unity3d 数学的数学基础和辅助类
转载注明smartdot:http://my.oschina.net/u/243648/blog/67193 1. 数学(点乘/叉乘)/unity3d的数学辅助类 2. 坐标系统(本地/世界/屏幕 ...
- AI 学习路线
[导读] 本文由知名开源平台,AI技术平台以及领域专家:Datawhale,ApacheCN,AI有道和黄海广博士联合整理贡献,内容涵盖AI入门基础知识.数据分析挖掘.机器学习.深度学习.强化学习.前 ...
随机推荐
- iOS事件机制(二)
从上一篇的内容我们知道,在iOS中一个事件用一个UIEvent对象表示,UITouch用来表示一次对屏幕的操作动作,由多个UITouch对象构成了一个UIEvent对象.另外,UIResponder是 ...
- Gym 100507L Donald is a postman (水题)
Donald is a postman 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/L Description Donald ...
- ZOJ 4114 Detect the Virus(AC自动机)
Detect the Virus Time Limit: 2 Seconds Memory Limit: 65536 KB One day, Nobita found that his co ...
- DllImport属性详解
API函数是构筑Windows的基石, 是Windows编程的必备利器.每一种Windows应用程序开发工具都提供间接或者直接的方式调用Win32API,C#也不例外.使用Win32API的一个好处就 ...
- 语义Web和本体开发相关技术
在技术实现方面,语义Web和本体理论的研究日趋成熟,已经有许多成熟的工具或程序接口,诸如Jena.OWL API等API是系统实现的关键技术.这里介绍系统的可行性分析以及系统开发设计的关键技术. 1 ...
- Hadoop本地库
目的 鉴于性能问题以及某些Java类库的缺失,对于某些组件,Hadoop提供了自己的本地实现. 这些组件保存在Hadoop的一个独立的动态链接的库里.这个库在*nix平台上叫libhadoop.so. ...
- Date String转换
这种转换要用到java.text.SimpleDateFormat类 字符串转换成日期类型: 方法1: 也是最简单的方法 Date date=new Date("2008-04-14&quo ...
- Java二维码登录流程实现(包含短地址生成,含部分代码)
近年来,二维码的使用越来越风生水起,笔者最近手头也遇到了一个需要使用二维码扫码登录网站的活,所以研究了一下这一套机制,并用代码实现了整个流程,接下来就和大家聊聊二维码登录及的那些事儿. 二维码原理 二 ...
- 推荐一个CodeProject上的SlideForm控件
CodeProject有一篇文章介绍了怎么实现一个SlideForm,非常不错,收藏在此. http://www.codeproject.com/KB/dialog/csslideform.aspx ...
- ASP.NET 尖括号 百分号 井号 等号 的用法
1.<%=%> 尖括号 百分号 等号 里面放的变量或方法,如: <div> <h1>Hello World</h1> <p><%= ...