【基础数学知识】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入门基础知识.数据分析挖掘.机器学习.深度学习.强化学习.前 ...
随机推荐
- struts2+Hibernate4+spring3+EasyUI环境搭建之一:准备工作
SSHE环境搭建第一步:安装软件(经验:安装软件路径最好不要有空格.括弧.中文等特殊符号)1.Jdk72.tomcat73.maven34.MyEclipse10.7 破解及优化设置(设置本地安装jd ...
- 汇总:Linux下svn命令大全
svn(subversion)是近年来崛起的版本管理工具,svn服务器有2种运行方式:独立服务器和借助apache.2种方式各有利弊.不管是那种方式,都需要使用各种命令来实现.在本文中,haohtml ...
- C#学习笔记(十五):预处理指令
C#和C/C++一样,也支持预处理指令,下面我们来看看C#中的预处理指令. #region 代码折叠功能,配合#endregion使用,如下: 点击后如下: 条件预处理 条件预处理可以根据给出的条件决 ...
- How to do Mathematics
著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:匿名用户链接:http://www.zhihu.com/question/30087053/answer/47815698来源 ...
- 普通Jquery的ajax判断重复和formvalidator的ajaxValidator区别
示例:1.ajax版: $("#txtTitle").blur(function () { $.ajax({ ...
- MFC视图切换大全总结
单纯视图之间的切换 单文档多视图切换是我在学习MFC中遇到的一个老大难问题,在今天总算是一一破解了.我觉得视图切换分为三个等级,第一是在未切分窗格的情况下切换视图类:第二是在分割窗格的一个窗格内实行视 ...
- getDefinitionByName与ApplicationDomain.getDefinition
主swf 定义:MC,被加载swf 定义:MC.MC1 ①父SWF的应用程序域的新建子域 (默认方式)称其为应用程序域的继承 var app:ApplicationDomain=new Applica ...
- CDOJ 486 Good Morning 傻逼题
Good Morning Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/486 ...
- delphi res 字符串资源
delphi res 字符串资源 (2011/12/10 19:19:36) //res 字符串资源 //rc 文件:StringTablebegin0 "AAAA"1 " ...
- delphi 01设置 字体属性
设置/获取 字体属性 名称 大小 粗体 斜体 下划线 删除线 颜色1 颜色2 uses MSHTML; //设置 //------------------------------------- ...