HDU 6205[计算几何,JAVA]
题目链接【http://acm.hdu.edu.cn/showproblem.php?pid=6206】
题意:
给出不共线的三个点,和一个点(x,y),然后判断(x,y)在不在这三个点组成的圆外。
题解:
咋一看很简单,实际也很简单,但是坐标都很大,会爆long double,怎么办?只有用java了。
公式:
a = ((y2 - y1) * (y3 * y3 - y1 * y1 + x3 * x3 - x1 * x1) - (y3 - y1) * (y2 * y2 - y1 * y1 + x2 * x2 - x1 * x1)) / (2.0 * ((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)));
b = ((x2 - x1) * (x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1) - (x3 - x1) * (x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1)) / (2.0 * ((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1)));
r ^ 2 = (x1 - a) * (x1 - a) + (y1 - b) * (y1 - b);
import java.util.Scanner;
import java.math.BigDecimal;
import java.io.BufferedInputStream; public class Main { public static void main(String[] args) {
Scanner cin = new Scanner(new BufferedInputStream(System.in));
BigDecimal x1, y1, x2, y2, x3, y3, x, y;
int T = cin.nextInt();
for (int k = 1; k <= T; k++) {
x1 = cin.nextBigDecimal();
y1 = cin.nextBigDecimal();
x2 = cin.nextBigDecimal();
y2 = cin.nextBigDecimal();
x3 = cin.nextBigDecimal();
y3 = cin.nextBigDecimal();
x = cin.nextBigDecimal();
y = cin.nextBigDecimal(); BigDecimal t1 = y2.subtract(y1);
BigDecimal t2 = y3.multiply(y3);
t2 = t2.subtract(y1.multiply(y1));
t2 = t2.add(x3.multiply(x3));
t2 = t2.subtract(x1.multiply(x1));
BigDecimal t3 = y3.subtract(y1);
BigDecimal t4 = y2.multiply(y2);
t4 = t4.subtract(y1.multiply(y1));
t4 = t4.add(x2.multiply(x2));
t4 = t4.subtract(x1.multiply(x1));
BigDecimal t5 = (x3.subtract(x1)).multiply(y2.subtract(y1));
t5 = t5.subtract(x2.subtract(x1).multiply(y3.subtract(y1)));
t5 = t5.multiply(BigDecimal.valueOf(2.0));
BigDecimal a = ((t1.multiply(t2)).subtract(t3.multiply(t4))).divide(t5); t1 = x2.subtract(x1);
t3 = x3.subtract(x1);
t5 = (y3.subtract(y1)).multiply(x2.subtract(x1));
t5 = t5.subtract(y2.subtract(y1).multiply(x3.subtract(x1)));
t5 = t5.multiply(BigDecimal.valueOf(2.0));
BigDecimal b = ((t1.multiply(t2)).subtract(t3.multiply(t4))).divide(t5);
BigDecimal r = (x1.subtract(a)).multiply(x1.subtract(a));
r = r.add((y1.subtract(b)).multiply(y1.subtract(b))); BigDecimal R = (x.subtract(a)).multiply(x.subtract(a));
R = R.add((y.subtract(b)).multiply(y.subtract(b)));
if(R.compareTo(r) > 0) {
System.out.println("Accepted");
}
else {
System.out.println("Rejected");
}
}
}
}
HDU 6205[计算几何,JAVA]的更多相关文章
- hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 2202 计算几何
最大三角形 Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- *HDU 2108 计算几何
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 6205 2017沈阳网络赛 思维题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6205 题意:给你n堆牌,原本每一堆的所有牌(a[i]张)默认向下,每次从第一堆开始,将固定个数的牌(b ...
- hdu 3320 计算几何(三维图形几何变换)
openGL Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- *HDU 1007 计算几何
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- *HDU 1392 计算几何
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- *HDU 1115 计算几何
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- *HDU 1086 计算几何
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
随机推荐
- 【BZOJ】4358: permu 莫队算法
[题意]给定长度为n的排列,m次询问区间[L,R]的最长连续值域.n<=50000. [算法]莫队算法 [题解]考虑莫队维护增加一个数的信息:设up[x]表示数值x往上延伸的最大长度,down[ ...
- 【BZOJ】3991: [SDOI2015]寻宝游戏 虚树+DFS序+set
[题意]给定n个点的带边权树,对于树上存在的若干特殊点,要求任选一个点开始将所有特殊点走遍后返回.现在初始没有特殊点,m次操作每次增加或减少一个特殊点,求每次操作后的总代价.n,m<=10^5. ...
- NYOJ 117 求逆序数 (树状数组)
题目链接 描述 在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序.一个排列中逆序的总数就称为这个排列的逆序数. 现在,给你一个N个元素的序列,请你判断出 ...
- Django之利用ajax实现图片预览
利用ajax实现图片预览的步骤为: 程序实现的方法为: 方法一: upload.html <!DOCTYPE html> <html lang="en"> ...
- Solaris 系统命令使用说明
1. 查看进程 -- pgreproot@UA4300D-spa:~# pgrep fmd133095root@UA4300D-spa:~# pgrep -l fmd133095 fmdroot@ ...
- py,pyc,pyw文件的区别和使用
熟悉python编程的都知道,python三种最常见的py文件格式,.py,.pyc,.pyw,下面说一说它们各自的使用. py文件 python最常见的文件,是python项目的源码: 文件执行时l ...
- 树莓派开发系列教程3--ssh、vnc远程访问
注意:树莓派系列的3篇文章里面的图片因为博客转移过程丢失了,非常抱歉 前言 远程访问有很多种方式可以实现.比如ssh.telnet.ftp.samba.远程桌面等等,各有优缺点.本文主要以ssh和远程 ...
- 2016 ACM ICPC Asia Region - Tehran
2016 ACM ICPC Asia Region - Tehran A - Tax 题目描述:算税. solution 模拟. B - Key Maker 题目描述:给出\(n\)个序列,给定一个序 ...
- Windows: 如何配置IPv6隧道
清空隧道配置: netsh interface ipv6 set teredo disable netsh interface ipv6 6to4 set state disable netsh in ...
- 湖南省第十一届大学生程序设计竞赛:Internet of Lights and Switches(HASH+二分+异或前缀和)
Internet of Lights and Switches Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 3 Solved: 3[Submit][ ...