hdu 6206 Apple(Java大数)
来源:互联网 发布:西瓜影音mac 编辑:程序博客网 时间:2024/06/05 18:48
Apple
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 806 Accepted Submission(s): 267
Problem Description
Apple is Taotao's favourite fruit. In his backyard, there are three apple trees with coordinates (x1,y1) , (x2,y2) , and (x3,y3) . Now Taotao is planning to plant a new one, but he is not willing to take these trees too close. He believes that the new apple tree should be outside the circle which the three apple trees that already exist is on. Taotao picked a potential position (x,y) of the new tree. Could you tell him if it is outside the circle or not?
Input
The first line contains an integer T , indicating that there are T(T≤30) cases.
In the first line of each case, there are eight integersx1,y1,x2,y2,x3,y3,x,y , as described above.
The absolute values of integers in input are less than or equal to1,000,000,000,000 .
It is guaranteed that, any three of the four positions do not lie on a straight line.
In the first line of each case, there are eight integers
The absolute values of integers in input are less than or equal to
It is guaranteed that, any three of the four positions do not lie on a straight line.
Output
For each case, output "Accepted" if the position is outside the circle, or "Rejected" if the position is on or inside the circle.
Sample Input
3-2 0 0 -2 2 0 2 -2-2 0 0 -2 2 0 0 2-2 0 0 -2 2 0 1 1
Sample Output
AcceptedRejectedRejected
在这个题目中找个好几个模板,最后确定为点击打开链接;但是里面的除法对于Java大数来说一个变量是不能除的。
但是这个题目要求的是判断是否在圆的内部,所以干脆直接都乘以G再做比较,避免了精度缺失。
代码如下:
import java.math.BigDecimal;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); BigDecimal A,B,C,G; BigDecimal x1,x2,x3,y1,y2,y3,x0,y0; BigDecimal X,Y; int t; t=cin.nextInt(); while(t-->0) { x1=cin.nextBigDecimal(); y1=cin.nextBigDecimal(); x2=cin.nextBigDecimal(); y2=cin.nextBigDecimal(); x3=cin.nextBigDecimal(); y3=cin.nextBigDecimal(); x0=cin.nextBigDecimal(); y0=cin.nextBigDecimal(); A=x1.multiply(x1).add(y1.multiply(y1)); B=x2.multiply(x2).add(y2.multiply(y2)); C=x3.multiply(x3).add(y3.multiply(y3)); G=BigDecimal.valueOf(1); G=y3.subtract(y2).multiply(x1).add(y1.subtract(y3).multiply(x2)).add(y2.subtract(y1).multiply(x3)); X=B.subtract(C).multiply(y1).add(C.subtract(A).multiply(y2)).add(A.subtract(B).multiply(y3)).divide(BigDecimal.valueOf(2)); Y=C.subtract(B).multiply(x1).add(A.subtract(C).multiply(x2)).add(B.subtract(A).multiply(x3)).divide(BigDecimal.valueOf(2)); x0=x0.multiply(G); y0=y0.multiply(G); x1=x1.multiply(G); y1=y1.multiply(G); BigDecimal a=x0.subtract(X).multiply(x0.subtract(X)).add( y0.subtract(Y).multiply(y0.subtract(Y))); BigDecimal b=x1.subtract(X).multiply(x1.subtract(X)).add( y1.subtract(Y).multiply(y1.subtract(Y))); if(a.compareTo(b)>0) System.out.println("Accepted"); else System.out.println("Rejected"); } }}
阅读全文
0 0
- hdu 6206 Apple(Java大数)
- HDU 6206 Apple (java大实数)
- HDU 6206 Apple(外心)
- 【java 大数】hdu java 大数
- HDU 6206 Apple 2017ICPC青岛网赛 A (高精度+大数模版)
- 大数删除k位是否能整除3,MG loves apple(HDU)
- HDU Divided Land(Java大数,二进制大数最大公约数)
- HDU 6206 Apple(高精度浮点数)
- HDU 6206 Apple (数学 高精度计算)
- HDU 6206 Apple(高精度C++)
- hdu 6206 Apple
- HDU 6206 Apple
- HDU高精度总结(java大数类)
- hdu 4927 Series 1(JAVA大数)
- hdu 1042 N! (java大数)
- HDU高精度总结(java大数类)
- HDU 5047 Sawtooth (JAVA大数类)
- hdu-5429(大数java练习)
- Python爬虫学习笔记Day3
- 换钱的方法数
- Android 常用三方网络及图片框架知识对比
- 关于使用bat执行jar包
- linux 技巧:使用 screen 管理你的远程会话
- hdu 6206 Apple(Java大数)
- 第四章 INI配置
- Cocos Creator 前言
- 最简单的非模块化的vue笔记
- 005_Tomcat环境配置与Tomcat项目部署
- laravel的request里的get和input区别
- centOS 安装tomcat
- 构造函数调用顺序
- 生命游戏Java实现