Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Monday 31 October 2016


Z. Point and the Circle
Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/Z


Score: 1

CPU: 1s
Memory: 512MB

Suppose you have a circle which has the center x, y and the radius of the circle is r. There is another point G (x1,y1). You have to find out that, whether the point is inside the circle or outside the circle. 

Input
First you will be given an positive integer T (1< T < 100), the number of test case. For each test case you will be given r, x, y, x1and y1 (-1000 < x, y, x1, y1 < 1000 ) in different lines.
Output
For each test case first you have to print “Case #:”, where # is the case number. Then if point G is inside the circle then print “YES” and “NO” if not

Sample

InputOutput
2 5 0 0 5 0 10 0 0 5 5Case 1: NO Case 2: YES

Solution

#include<stdio.h>
#include<math.h>
int main()
{
    double x,y,r,a,b,res=0;
    int i,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%lf%lf%lf%lf%lf",&r,&a,&b,&x,&y);
        res=sqrt((a-x)*(a-x)+(b-y)*(b-y));
        if(res<r){
            printf("Case %d: YES\n",i);
        }
        else{
            printf("Case %d: NO\n",i);
        }
    }

    return 0;
}

No comments:

Post a Comment