• 2017 ACMICPC Asia Regional Qingdao Online 1001 Apple


    Time Limit: 1000/1000 MS(Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
    Total Submission(s): 0    Accepted Submission(s): 0


    Problem Description

    Apple is Taotao's favouritefruit. In his backyard, there are three apple trees with coordinates (x1,y1), (x2,y2), and (x3,y3). Now Taotao is planning toplant a new one, but he is not willing to take these trees too close. Hebelieves that the new apple tree should be outside the circle which the threeapple trees that already exist is on. Taotao picked a potential position (x,y) of the new tree. Couldyou tell him if it is outside the circle or not?

    Input

    The first line contains aninteger T, indicating that there are T(T≤30) cases.
    In the first line of each case, there are eight integers x1,y1,x2,y2,x3,y3,x,y, as described above.
    The absolute values of integers in input are less than or equal to 1,000,000,000,000.
    It is guaranteed that, any three of the four positions do not lie on a straightline.

    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

    Accepted
    Rejected
    Rejected

    最终代码还是wa

    #include <iostream>
    #include <cmath>
    #include <cstdio>
    using namespace std;
    typedef long long ll;
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            double x1,y1,x[5],y[5];
    
            double a,b,r;
            int i;
            for(i=1;i<=3;i++)
                scanf("%lf%lf",&x[i],&y[i]);
            scanf("%lf%lf",&x1,&y1);
            a = (x[2]*x[2]*y[1]-x[3]*x[3]*y[1]-x[1]*x[1]*y[2]+x[3]*x[3]*y[2]-y[1]*y[1]*y[2]+y[1]*y[2]*y[2]+x[1]*x[1]*y[3]-x[2]*x[2]*y[3]+y[1]*y[1]*y[3]-y[2]*y[2]*y[3]-y[1]*y[3]*y[3]+y[2]*y[3]*y[3])/(2* (x[2]* y[1] - x[3] *y[1] - x[1]* y[2] + x[3]* y[2] + x[1]* y[3] - x[2]* y[3]));
            b = -(-x[1]*x[1]* x[2] + x[1]*x[2]*x[2] + x[1]*x[1] *x[3] - x[2]*x[2]* x[3] - x[1]* x[3]*x[3] + x[2]*  x[3]*x[3] - x[2] *y[1]*y[1] + x[3] *y[1]*y[1] + x[1] *y[2]*y[2] - x[3] *y[2]*y[2] - x[1]* y[3]*y[3] + x[2]* y[3]*y[3])/(2 *(x[2] *y[1] - x[3]* y[1] - x[1] *y[2] + x[3] *y[2] + x[1] *y[3] - x[2]* y[3]));
            r = sqrt((x[1]-a)*(x[1]-a) + (y[1]-b)*(y[1]-b));
            //printf("%lf %lf %lf
    ",a,b,r);
            double t = sqrt((x1-a)*(x1-a) + (y1-b)*(y1-b));
            if(t>r)
                printf("Accepted
    ");
            else
                printf("Rejected
    ");
        }
        return 0;
    }
    


  • 相关阅读:
    排序算法与数据结构复习总结
    Kafka知识总结及面试题
    深入理解Redis系列之事务
    深入理解Redis系列之持久化
    基于数据库、redis和zookeeper实现的分布式锁
    深入理解MySQL系列之优化
    Mysql-主从复制(Docker)
    Mysql-GTID主从复制
    Ansible基础
    Nginx + php-fpm源码编译
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586261.html
Copyright © 2020-2023  润新知