Z. Point and the Circle
Problem linkhttps://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/Z
Score: 1
CPU: 1s
Memory: 512MB
CPU: 1s
Memory: 512MB
Suppose you have a circle which has the center
Input
First you will be given an positive integer
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, x1
and y1 (-1000 < x, y, x1, y1 < 1000 )
in different lines.
Output
For each test case first you have to print “
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 notSample
Input | Output |
---|---|
2 5 0 0 5 0 10 0 0 5 5 | Case 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