好不容易找到的。

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
double a,b,c,x,y,z,ans,l,w,h;
double f(double x)
{
return (double(x*x));
} double min(double x,double y)
{
if(x>y) return y;
else return x;
} void count1()
{
ans=sqrt(double(f(a-x)+f(b-y)+f(c-z)));
} void count2()
{
double ans1,ans2;
if(b==||b==w)
{
ans1=sqrt(double(min(f(h-z+w+h-c),f(z+w+c))+f(x-a)));
ans2=sqrt(double(min(f(l-x+w+l-a),f(x+w+a))+f(c-z)));
}
else if(a==||a==l)
{
ans1=sqrt(double(min(f(w-y+l+w-b),f(y+l+b))+f(c-z)));
ans2=sqrt(double(min(f(h-z+l+h-c),f(z+l+c))+f(b-y)));
}
else
{
ans1=sqrt(double(min(f(w-y+h+w-b),f(y+h+b))+f(x-a)));
ans2=sqrt(double(min(f(l-x+h+l-a),f(x+h+a))+f(b-y)));
}
ans=min(ans1,ans2);
} void count3()
{
if(a==||a==l)
{
if(y==||y==w)
ans=sqrt(double(f(labs(x-a)+labs(b-y))+f(c-z)));
else
ans=sqrt(double(f(labs(z-c)+labs(x-a))+f(b-y)));
}
else if(b==||b==w)
{
if(x==||x==l)
ans=sqrt(double(f(labs(x-a)+labs(b-y))+f(c-z)));
else
ans=sqrt(double(f(labs(c-z)+labs(b-y))+f(a-x)));
}
else
{
if(x==||x==l)
ans=sqrt(double(f(labs(c-z)+labs(x-a))+f(b-y)));
else
ans=sqrt(double(f(labs(c-z)+labs(b-y))+f(a-x)));
}
} int main()
{
cin>>l>>w>>h;
cin>>a>>b>>c>>x>>y>>z;
if((a==x&&(a==||a==l))||(b==y&&(b==||b==w))||(c==z&&(c==||c==h)))
count1();
else if((a==&&x==l)||(b==&&y==w)||(c==&&z==h)||(a==l&&x==)||(b==w&&y==)||(c==h&&z==))
count2();
else
count3();
cout<<setiosflags(ios::fixed)<<setprecision()<<ans<<endl;
return ;
}

【算法】shortest distance的更多相关文章

  1. PAT Advanced 1046 Shortest Distance (20 分) (知识点:贪心算法)

    The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed t ...

  2. PAT——甲级1046S:shortest Distance

    这道题,折磨了我一个多小时,前前后后写了三个算法. 1046 Shortest Distance (20 point(s)) The task is really simple: given N ex ...

  3. A1046 Shortest Distance (20)(20 分)

    1046 Shortest Distance (20)(20 分)提问 The task is really simple: given N exits on a highway which form ...

  4. 【LeetCode】1182. Shortest Distance to Target Color 解题报告 (C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+二分查找 日期 题目地址:https://lee ...

  5. [CareerCup] 18.5 Shortest Distance between Two Words 两单词间的最短距离

    18.5 You have a large text file containing words. Given any two words, find the shortest distance (i ...

  6. [Locked] Shortest Distance from All Buildings

    Shortest Distance from All Buildings You want to build a house on an empty land which reaches all bu ...

  7. maximum shortest distance

    maximum shortest distance Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...

  8. PAT1046: Shortest Distance

    1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...

  9. [Swift]LeetCode821. 字符的最短距离 | Shortest Distance to a Character

    Given a string S and a character C, return an array of integers representing the shortest distance f ...

  10. LeetCode 613. Shortest Distance in a Line

    Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. Writ ...

随机推荐

  1. .net core下简单构建高可用服务集群

    一说到集群服务相信对普通开发者来说肯定想到很复杂的事情,如zeekeeper ,反向代理服务网关等一系列的搭建和配置等等:总得来说需要有一定经验和规划的团队才能应用起来.在这文章里你能看到在.net ...

  2. Puppeteer 截图及相关问题

    Puppeteer 是 Headless Chrome 的 Node.js 封装.通过它可方便地对页面进行截图,或者保存成 PDF. 镜像的设置 因为其使用了 Chromium,其源在 Google ...

  3. Hadoop伪分布式集群搭建

    声明:作者原创,转载注明出处. 作者:帅气陈吃苹果 1.下载Hadoop压缩包 wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop- ...

  4. django-restframework 处理跨域问题

    django-restframework 处理跨域问题 一 前言 想要处理跨域问题,首先需要了解同源策略. 二 同源策略 同源策略(Same origin policy)是一种约定,它是浏览器最核心也 ...

  5. relief中visio图出现问题处理

    需安装visio2010版本, 安装DsoFramer_KB311765_x86.exe 管理员权限打开cmd,运行regsvr32 dsoframer.ocx

  6. Java学习点滴——Class和反射

    基于<Java编程思想>第四版 前言 我们要操作一个类实例对象时,一般都要先知道这个类有哪些方法或者成员变量.反射就是在我们不知道这个类有哪些方法或成员变量时,使用特定方式得到类的这些信息 ...

  7. 20190421-那些年使用过的CSS预处理器(CSS Preprocessor)

    写在前面的乱七八糟的前言: emmm,不得不说,早上七点是个好时间,公园里跳广场舞的大妈,街边卖菜刀看报的大爷,又不得不说,广州图书馆是个好地方,该有的安静,该有的人气,听着楼下小孩子的声音,看着周围 ...

  8. phpstorm:如何设置代码自动换行

    File->Settings->Editor 点击general,如下如所示: 勾选 “ Use soft wrap in editor ”    ,这样就可以自动换行了

  9. elementUi的时间选择器在IE浏览器的赋值问题--前端

    项目技术:vue+elementUi,组件化 出现的问题:在IE浏览器(IE10+),唤醒组件加载赋值,表单中el-input等框赋值正确,el-date-picker选择器没有显示所附的值(或显示p ...

  10. 关于elementui表单数字校验踩坑记

    需求:1.输入类型是数字.2.数字大小有限制.3.非必填 做法: <el-form-item label="熟悉程度" prop="averageCaseRunTi ...