poj 1673 EXOCENTER OF A TRIANGLE

Given a triangle ABC, the Extriangles of ABC are constructed as follows: 
On each side of ABC, construct a square (ABDE, BCHJ and ACFG in the figure below). 
Connect adjacent square corners to form the three Extriangles (AGD, BEJ and CFH in the figure). 
The Exomedians of ABC are the medians of the Extriangles, which pass through vertices of the original triangle,extended into the original triangle (LAO, MBO and NCO in the figure. As the figure indicates, the three Exomedians intersect at a common point called the Exocenter (point O in the figure). 
This problem is to write a program to compute the Exocenters of triangles. 

Input

The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each dataset consists of 3 lines; each line contains two floating point values which represent the (two -dimensional) coordinate of one vertex of a triangle. So, there are total of (n*3) + 1 lines of input. Note: All input triangles wi ll be strongly non-degenerate in that no vertex will be within one unit of the line through the other two vertices.

Output

For each dataset you must print out the coordinates of the Exocenter of the input triangle correct to four decimal places.

Sample Input

2
0.0 0.0
9.0 12.0
14.0 0.0
3.0 4.0
13.0 19.0
2.0 -10.0

Sample Output

9.0000 3.7500
-48.0400 23.3600

求的是垂心 直接套公式

但是不知道为什么 大神说答案要加上1e-8才能过 以后几何题都要加1e-8再输出


#include <stdio.h>

int main()
{
	int cas;
	scanf("%d",&cas);
	double x1,y1,x2,y2,x3,y3,x,y;
	while(cas--)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		printf("%.4lf ",1e-8 + -( (x1 *x2* y1) - (x1* x3* y1) - (x1* x2* y2) + (x2* x3* y2) + (y1*y1* y2) - (y1* y2*y2) + (x1* x3* y3) - (x2* x3* y3) - (y1*y1* y3) + (y2*y2* y3) + (y1 *y3*y3) - (y2* y3*y3) )/( (-x2* y1) + (x3 *y1) + (x1 *y2) - (x3* y2) - (x1* y3) + (x2 *y3)) );
		printf("%.4lf\n",1e-8 + -( (x1*x1* x2) - (x1* x2*x2) - (x1*x1* x3) + (x2*x2* x3) + (x1* x3*x3) - (x2* x3*x3) + (x1* y1 *y2 )- (x2* y1* y2) - (x1* y1* y3) + (x3* y1* y3) + (x2* y2* y3) - (x3* y2* y3) )/( (x2* y1) - (x3* y1) - (x1* y2) + (x3 *y2) + (x1* y3) - (x2* y3)));
	}
	return 0;
}




### JVM垃圾收集器的工作原理 JVM中的垃圾收集器负责自动管理和释放不再使用的内存资源。这一过程对于维护Java应用程序的性能至关重要[^1]。垃圾收集的主要目标是在不影响应用正常运行的前提下尽可能高效地回收无用对象所占有的空间。 #### 垃圾收集器类型及其特性 多种类型的垃圾收集器存在于现代版本的JVM中,每种都有各自的设计理念来适应特定应用场景下的需求: - **Serial GC**:适用于单核处理器的小规模应用环境,在年轻代采用复制算法,在老年代则使用标记-整理算法。 - **Parallel GC (也称为Throughput Collector)**:专为多CPU系统设计,旨在最大化吞吐量,即完成更多有用工作的比例相对于总执行时间而言。该收集器同样区分新生代与年老代,并分别运用不同的清理策略以达到最佳效果。 - **CMS (Concurrent Mark-Sweep) GC**:专注于降低暂停时间而非整体效率,适合于那些对响应速度敏感的服务端程序。它可以在后台逐步扫描存活对象并清除死亡对象而不必完全停止整个应用程序进程。 - **G1 (Garbage First) GC**:自JDK 7更新版引入以来成为默认选项之一,特别擅长处理具有大量活跃数据的大容量堆配置。G1将整个堆划分为多个固定大小的区域(region),并通过预测哪些地区最有可能包含可回收的空间来进行优先级排序。 - **ZGC 和 Shenandoah GC**:这两种新型低延迟垃圾收集器是从JDK 11开始加入的支持超大型堆(可达数TB级别)的同时具备亚毫秒级别的短暂停滞特性的工具[ZGC][^5]。它们都采用了先进的并发技术使得大部分垃圾回收活动能够在不停止用户线程的情况下发生。 ### 如何选择合适的垃圾收集器? 选择最适合项目需求的垃圾收集器取决于具体的应用场景以及期望达成的目标。如果追求最高的吞吐率,则可能倾向于使用`Parallel GC`; 若更看重快速反应时间和较低的停顿频率,那么像`CMS`, `G1`, 或者最新的`ZGC/Shenandoah`可能是更好的选择。值得注意的是,“最优”的方案并非永恒不变——随着业务逻辑的发展和技术进步,原先选定的最佳实践可能会变得不合适,因此定期审查当前设置总是明智之举[^2]。 ### 性能调优建议 为了使选中的垃圾收集器发挥最大效能,可以通过调整一系列参数来进行精细化控制。这包括但不限于设定初始/最大堆尺寸(-Xms/-Xmx), 新生代占比(-XX:NewRatio), 生存阈值(-XX:+UseAdaptiveSizePolicy,-XX:MaxTenuringThreshold)等。此外,启用详细的日志记录功能可以帮助诊断潜在瓶颈所在之处,从而指导后续改进措施的方向。最终目的是找到一个平衡点,在满足服务等级协议(SLA)关于响应时间和吞吐量的要求之间取得良好折衷。 ```bash java -Xms512m -Xmx4g -XX:+UseG1GC MyApplication ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值