CodeMarshal Solution - বৃত্তের ভিতরে বিন্দু ( Point Inside Circle ) in C :
CodeMarshal Online Judge Solution Point Inside Circle
CodeMarshal Main Problem Link - https://algo.codemarshal.org/problems/55184554742a2fff09a42faa
Problem Name: CodeMarshal Problem Point Inside Circle
Problem Number : CodeMarshal Problem Point Inside Circle Solution
Online Judge : CodeMarshal Online Judge Solution
Solution Language : C
CodeMarshal Solution Point Inside Circle in C :
Noted thing:
In this example, it is declared that - No float or double types of variable is not allowed. But using normal int n, we can't get the exact proper solutions for all cases. So just take long long int all of the values for getting 100% Solution.
long long int cx, cy, px, py, r, distance;
And have to remember that to take long long int value in c you have to use - %lld. Look this scanf line,
scanf("%lld %lld %lld %lld %lld", &cx, &cy, &r, &px, &py);
And then find the distance between the points from the circles center at this line-
distance = sqrt(pow((cx - px), 2) + pow((cy - py), 2));
Final 100% Solution in basic C:
#include <stdio.h> #include<math.h> int main () { int i, j, n; scanf("%d", &n); for(i = 1; i <= n; i++) { long long int cx, cy, px, py, r, distance; scanf("%lld %lld %lld %lld %lld", &cx, &cy, &r, &px, &py); distance = sqrt(pow((cx - px), 2) + pow((cy - py), 2)); if(distance < r) { printf("Case %d: %s\n", i, "yes"); } else { printf("Case %d: %s\n", i, "no"); } } return 0; }
No comments:
Post a Comment