Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

死活不过啊,都用的INT型了,精度不能不够啊?哪位大牛指点一下!

Posted by xyjian at 2007-10-25 11:32:16 on Problem 1675
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pi (acos(-1))
#define eq 1e-10

struct point {
    int x, y;
};    

int mul (point a, point b, point z) {
    return((a.x-z.x)*(b.y-z.y)-(b.x-z.x)*(a.y-z.y));
}    

bool rad(point a, point b) {
    point z;
    z.x = 0;
    z.y = 0;
    if(mul(a, b, z)<0) {
        return false;
    }    
    if ((a.x * b.x + a.y * b.y) < 0 && (a.x * b.x + a.y * b.y) * (a.x * b.x + a.y * b.y) > (a.x * a.x + a.y * a.y) * (b.x * b.x + b.y * b.y) / 4) {
        return false;
    } 
    return true;
}    

int main () {
    int casen;
    int r;
    point a, b, c;
    bool z;
    
    for(scanf("%d", &casen); casen; casen -- ){
        z = false;
        scanf("%d", &r);
        scanf("%d%d", &a.x, &a.y);
        if(a.x == 0 && a.y == 0) {
            z = true;
        }    
        scanf("%d%d", &b.x, &b.y);
        if(b.x == 0 && b.y == 0) {
            z = true;
        }    
        scanf("%d%d", &c.x, &c.y);
        if(c.x == 0 && c.y == 0 ) {
            z = true;
        }    
        
        if(z) {
            printf("No\n");
            continue;
        }    
        
    //    printf("%lf  %lf  %lf %lf\n", rad(a, b), rad(a, c), rad(b, c), 2*pi/3);
        if((rad(a, b) && rad(a, c))
        || (rad(b, a) && rad(b, c))
        || (rad(c, b) && rad(c, a))) {
            printf("No\n");
        }    
        else {
            printf("Yes\n");
        }    
    }    
    return 0;
}    

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator