题意:就是求里面的六边形的每条边的距离

思路:直接求就好了(把题目标号的顺序读反了,保佑队友不杀之恩)

代码:

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define zero(a) fabs(a)<eps
#define max( x, y )  ( ((x) > (y)) ? (x) : (y) )
#define min( x, y )  ( ((x) < (y)) ? (x) : (y) )
#define lowbit(x) (x&(-x))
#define debug(a) cerr<<#a<<"=="<<a<<endl
typedef long long LL;
const long double pi=acos(-1.0);
const long double eps=1e-8;
const int inf=0x3f3f3f3f;
const LL linf=0x3f3f3f3f3f3f3f3f;
using namespace std;#define zero(x) (((x)>0?(x):-(x))<eps)
int sgn(long double x)
{if(fabs(x) < eps)return 0;if(x < 0)return -1;else return 1;
}
struct point
{long double x,y;point (){}point (long double _x,long double _y){x=_x,y=_y;}
};
struct Line
{point a,b;Line(){}Line(point _a,point _b){a=_a;b=_b;}
};
struct circle {point o;long double r;void print() {printf(" center:(%.4Lf, %.4Lf) rad: %.4Lf\n", o.x, o.y, r);}
};
long double xmult(point p1,point p2,point p0)
{return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
point intersection(point u1,point u2,point v1,point v2)
{point ret=u1;long double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))/((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));ret.x+=(u2.x-u1.x)*t;ret.y+=(u2.y-u1.y)*t;return ret;
}
point intersection(Line u,Line v)
{point ret=u.a;long double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));ret.x+=(u.b.x-u.a.x)*t;ret.y+=(u.b.y-u.a.y)*t;return ret;
}
long double dist(point a,point b)
{return (long double)sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
point circumcenter(point a,point b,point c)
{Line u,v;u.a.x=(a.x+b.x)/2;u.a.y=(a.y+b.y)/2;u.b.x=u.a.x-a.y+b.y;u.b.y=u.a.y+a.x-b.x;v.a.x=(a.x+c.x)/2;v.a.y=(a.y+c.y)/2;v.b.x=v.a.x-a.y+c.y;v.b.y=v.a.y+a.x-c.x;return intersection(u,v);
}
point incenter(point a,point b,point c)
{Line u,v;long double m,n;u.a=a;m=atan2(b.y-a.y,b.x-a.x);n=atan2(c.y-a.y,c.x-a.x);u.b.x=u.a.x+cos((m+n)/2);u.b.y=u.a.y+sin((m+n)/2);v.a=b;m=atan2(a.y-b.y,a.x-b.x);n=atan2(c.y-b.y,c.x-b.x);v.b.x=v.a.x+cos((m+n)/2);v.b.y=v.a.y+sin((m+n)/2);return intersection(u,v);
}
circle getNqc(point a, point b, point c) {long double C = dist(a, b);long double B = dist(a, c);long double A = dist(b, c);circle cir;cir.o.x = (A*a.x + B*b.x + C*c.x) / (A + B + C);cir.o.y = (A*a.y + B*b.y + C*c.y) / (A + B + C);cir.r = sqrt((A + B - C)*(A - B + C)*(-A + B + C) / (A + B + C)) / 2;return cir;
}
void intersection_line_circle(point c,long double r,point l1,point l2,point& p1,point& p2)
{point p=c;long double t;p.x+=l1.y-l2.y;p.y+=l2.x-l1.x;p=intersection(p,c,l1,l2);t=sqrt(r*r-dist(p,c)*dist(p,c))/dist(l1,l2);p1.x=p.x+(l2.x-l1.x)*t;p1.y=p.y+(l2.y-l1.y)*t;p2.x=p.x-(l2.x-l1.x)*t;p2.y=p.y-(l2.y-l1.y)*t;
}
Line line[10];int main()
{int T;scanf("%d",&T);while(T--){int p;long double t1,t2,t3;point A,B,C,I,P,N,M;cin>>p>>t1>>t2>>t3;A=point(0.0,0.0),B=point(t1,0),C=point(t2,t3);circle qwe=getNqc(A,B,C);I=qwe.o;point wo=circumcenter(A,B,C);long double wr=dist(A,wo);point a1,a2;intersection_line_circle(wo,wr,I,A,a1,a2);if(fabs(a1.x-A.x)<eps&&fabs(a1.y-A.y)<eps){M=a2;}else{M=a1;}intersection_line_circle(wo,wr,I,B,a1,a2);if(fabs(a1.x-B.x)<eps&&fabs(a1.y-B.y)<eps){N=a2;}else{N=a1;}intersection_line_circle(wo,wr,I,C,a1,a2);if(fabs(a1.x-C.x)<eps&&fabs(a1.y-C.y)<eps){P=a2;}else{P=a1;}point E,F,K,J,H,G;G=intersection(Line(A,C),Line(M,N));H=intersection(Line(M,N),Line(C,B));J=intersection(Line(C,B),Line(M,P));K=intersection(Line(M,P),Line(A,B));E=intersection(Line(A,B),Line(N,P));F=intersection(Line(N,P),Line(A,C));printf("%d %.4Lf %.4Lf %.4Lf %.4Lf %.4Lf %.4Lf\n",p,dist(E,F),dist(F,G),dist(G,H),dist(H,J),dist(J,K),dist(K,E));}return 0;
}
/*3
1 3 2.5 31
1 2 1 1.732
*/

转载于:https://www.cnblogs.com/lalalatianlalu/p/8984755.html

UVALive - 8295 Triangle to Hexagon相关推荐

  1. 有趣的超短python代码_Python 学习之——Python超短教程

    前言 本教程综合Stanford CS231N和UC Berkerley CS188的Python教程. 教程很短,但适合有一定编程基础,学过其他语言的童鞋. Python 启动Python 解释器 ...

  2. F - Heron and His Triangle UVALive - 8206

    F - Heron and His Triangle UVALive - 8206 题意: 给你应该n,然后求一个最小的t,问长度为t-1,t,t+1所组成的三角形的面积为整数,t>=n 题解: ...

  3. 暑假训练 The Triangle Game (OpenJ_Bailian - 1574)

    题目描述: In the triangle game you start off with six triangles numbered on each edge, as in the example ...

  4. 8155/8255/8295参数对比

    8255与8295同为高通第四台座舱芯片,大体上各项参数都差不多,某些参数8255更强,而有的参数则是8295更强一些.从价格上看,似乎8255比8295更有优势一些,未来有可能会成为新的主流座舱芯片 ...

  5. [JS][C++]两题斐波那契数列:上台阶、triangle

    上台阶 时间限制: 3000MS 内存限制: 589824KB 题目描述: 有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法? 注:规定从一级到一级有0种走法. ...

  6. DP UVALive 6506 Padovan Sequence

    题目传送门 /*题意:两行数字,相邻列一上一下,或者隔一列两行都可以,从左到右选择数字使和最大DP:状态转移方程:dp[i][j] = max (dp[i][j], dp[1-i][j-1] + a[ ...

  7. 设计一个扩展自抽象类geometricobject的新的triangle类_C++ 接口(抽象类)

    C++ 接口(抽象类) 接口描述了类的行为和功能,而不需要完成类的特定实现. C++ 接口是使用抽象类来实现的,抽象类与数据抽象互不混淆,数据抽象是一个把实现细节与相关的数据分离开的概念. 如果类中至 ...

  8. 帕斯卡三角形(Pascal's triangle)

    // The following code is compiled on VC2005 // #include "stdafx.h" /*--------------------- ...

  9. [leedcode 118] Pascal's Triangle

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Retu ...

  10. [LeetCode 120] - 三角形(Triangle)

    问题 给出一个三角形,找出从顶部至底部的最小路径和.每一步你只能移动到下一行的邻接数字. 例如,给出如下三角形: [ [2], [3,4], [6,5,7], [4,1,8,3] ] 从顶部至底部的最 ...

最新文章

  1. Linux Yum命令(转)
  2. 虎牙直播在微服务改造方面的实践和总结
  3. Eclipse 安装配置指南
  4. 适合网页设计师的11个不错的Chrome插件
  5. 设计模式之观察者模式在Listview中的应用
  6. c#中connect函数_C#.NET 各种连接字符串
  7. Linux统计目录下文件个数及代码行数
  8. UIButton 上的标题添加下划线效果
  9. day12 java的方法覆盖(重写)
  10. ASP.NET使用ConfigurationSection在Web.Config创建自定义配置节
  11. Android 轻松实现语音朗读
  12. 一个react项目案例02 注册和登陆实现原理分析
  13. 数字化营销的意义所在
  14. android通过经纬度获取地址,android之location 根据接口获取经纬度信息
  15. 一个软件项目的成本构成及评估方法
  16. 网络与信息安全方向顶刊顶会
  17. SFDC中的DEBUG
  18. 用Jquey实现双击图片放大和触摸放大的功能。
  19. java接口可以写方法体吗_JDK1.8接口中可以写方法体
  20. PL2303 Windows8.1驱动

热门文章

  1. 一个存储过程实现(问题答案)
  2. ARP解决方法/工具+真假ARP防范区别方法+ARP终极解决方案
  3. 我不应该用计算机做题,中考答题涂卡必须用2B铅笔,看到电脑扫描的试卷,才明白有多重要...
  4. 一对多关联关系映射和设置级联属性
  5. [渝粤教育] 山东大学 日本历史与文化 参考 资料
  6. 【渝粤教育】国家开放大学2018年春季 0092-22T民法 参考试题
  7. 【渝粤教育】国家开放大学2019年春季 3818-22T燃气工程施工 参考试题
  8. ajax同步时,loading加载不显示(谷歌浏览器)
  9. 自适应方案比较及案例
  10. Jmeter学习笔记4-集合点