Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Three way communication giving wrong output on codechef

$
0
0
# include <stdio.h>
# include <math.h>

inline int scan()
{
    char c = getchar_unlocked();
    while(c < '0' && c > '9')
    c = getchar_unlocked();
    int n = 0;
    while(c >= '0' && c <= '9')
    {
        n = n * 10 + c - '0';
        c = getchar_unlocked();
    }
    return n;
}

int main()
{
    int T = scan();
    int R, head[1][2], chef[1][2], sous[1][2];
    while(T--)
    {
        R = scan();
        chef[0][0] = scan();
        chef[0][1] = scan();
        head[0][0] = scan();
        head[0][1] = scan();
        sous[0][0] = scan();
        sous[0][1] = scan();
        float dis_ch = 0, dis_cs = 0, dis_hs = 0;
        dis_ch = sqrt(pow((head[0][0] - chef[0][0]),2) + pow((head[0][1] - chef[0][1]),2));
        dis_cs = sqrt(pow((sous[0][0] - chef[0][0]),2) + pow((sous[0][1] - chef[0][1]),2));
        dis_hs = sqrt(pow((head[0][0] - sous[0][0]),2) + pow((head[0][1] - sous[0][1]),2));
        if(dis_ch <= R && dis_hs <= R)
        printf("yes\n");
        else if(dis_cs <= R && dis_hs <= R)
        printf("yes\n");
        else if(dis_cs <= R && dis_ch <= R)
        printf("yes\n");
        else
        printf("no\n");
    }
    return 0;
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>