HDU
来源:互联网 发布:淘宝上怎么买定额发票 编辑:程序博客网 时间:2024/06/16 19:02
2017 ACM/ICPC Asia Regional Qingdao Online 1001
Apple
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
Source
2017 ACM/ICPC Asia Regional Qingdao Online
Recommend
liuyiding
解题思路:胜利属于JAVA。我现在只想看看C++高精度怎么做……
import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main (String[] args) { Scanner stdin = new Scanner(System.in); Main m = new Main(); int T = stdin.nextInt(); for(int i=0;i<T;i++){ BigDecimal x1 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal y1 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal x2 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal y2 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal x3 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal y3 = BigDecimal.valueOf(stdin.nextLong()); BigDecimal x = BigDecimal.valueOf(stdin.nextLong()); BigDecimal y = BigDecimal.valueOf(stdin.nextLong()); BigDecimal resx_part1 = y3.subtract(y1), resx_part2 = y2.multiply(y2).subtract(y1.multiply(y1)).add(x2.multiply(x2)).subtract(x1.multiply(x1)), resx_part3 = y2.subtract(y1), resx_part4 = y1.multiply(y1).subtract(y3.multiply(y3)).add(x1.multiply(x1)).subtract(x3.multiply(x3)), resx_partA = resx_part1.multiply(resx_part2), resx_partB = resx_part3.multiply(resx_part4), resx_partAlpha = resx_partA.add(resx_partB), resx_part5 = BigDecimal.valueOf(2).multiply(x2.subtract(x1)).multiply(y3.subtract(y1)), resx_part6 = BigDecimal.valueOf(2).multiply(x3.subtract(x1)).multiply(y2.subtract(y1)), resx_partBeta = resx_part5.subtract(resx_part6), resx = resx_partAlpha.divide(resx_partBeta), resy_part1 = x3.subtract(x1), resy_part2 = x2.multiply(x2).subtract(x1.multiply(x1)).add(y2.multiply(y2)).subtract(y1.multiply(y1)), resy_part3 = x2.subtract(x1), resy_part4 = x1.multiply(x1).subtract(x3.multiply(x3)).add(y1.multiply(y1)).subtract(y3.multiply(y3)), resy_partA = resy_part1.multiply(resy_part2), resy_partB = resy_part3.multiply(resy_part4), resy_partAlpha = resy_partA.add(resy_partB), resy_part5 = BigDecimal.valueOf(2).multiply(y2.subtract(y1)).multiply(x3.subtract(x1)), resy_part6 = BigDecimal.valueOf(2).multiply(y3.subtract(y1)).multiply(x2.subtract(x1)), resy_partBeta = resy_part5.subtract(resy_part6), resy = resy_partAlpha.divide(resy_partBeta), deltax1 = x1.subtract(resx), deltay1 = y1.subtract(resy), deltax1sq = deltax1.multiply(deltax1), deltay1sq = deltay1.multiply(deltay1), rsq = deltax1sq.add(deltay1sq); BigDecimal a = x.subtract(resx); BigDecimal b = y.subtract(resy); BigDecimal aa = a.multiply(a).add(b.multiply(b)); if(aa.compareTo(rsq)==1){ System.out.println("Accepted"); }else{ System.out.println("Rejected"); } } }}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- git安装和github使用
- day08-mysql表操作回顾(工作重点)
- Git的基本配置
- 9.17----对《暗时间》的随笔
- SVN分支管理以及跨分支打包
- HDU
- oracle部分函数
- Python绝技读书笔记之构建SSH僵尸网络
- Java中的3中注释
- 第三周项目4顺序表应用2 删除元素在[x,y]之间的所有元素
- 接口和抽象类的区别
- 【莫队 or 离线+树状数组】BZOJ1878(SDOI2009)[HH的项链]题解
- 1021. 个位数统计 (15)--PAT乙级
- MAVEN异常:Check $M2_HOME environment variable and mvn script match