Imagine Circle Country as an infinite plane. You are given int[] x and int[] y and int[] r, where (x[i],y[i]) are the coordinates of the i-th district's center and r[i] is its radius. Zara is currently at point (x1,y1) and she needs to get to point (x2,y2). Neither of these points lies on a district border. Return the minimal number of district borders she must cross to get to her destination. Constraints x will contain between 1 and 50 elements, inclusive. x, y and r will each contain the same number of elements. Each element of x and y will be between -1000 and 1000, inclusive. Each element of r will be between 1 and 1000, inclusive. x1, y1, x2 and y2 will be between -1000 and 1000, inclusive. No two circumferences will have common points. The points (x1,y1) and (x2,y2) will not lie on any of the circumferences.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Imagine Circle Country as an infinite plane. You are given int[] x and int[] y and int[] r, where (x[i],y[i]) are the coordinates of the i-th district's center and r[i] is its radius. Zara is currently at point (x1,y1) and she needs to get to point (x2,y2). Neither of these points lies on a district border. Return the minimal number of district borders she must cross to get to her destination.

Constraints

  • x will contain between 1 and 50 elements, inclusive.
  • x, y and r will each contain the same number of elements.
  • Each element of x and y will be between -1000 and 1000, inclusive.
  • Each element of r will be between 1 and 1000, inclusive.
  • x1, y1, x2 and y2 will be between -1000 and 1000, inclusive.
  • No two circumferences will have common points.
  • The points (x1,y1) and (x2,y2) will not lie on any of the circumferences.
3. {1, -3,2,5, -4,12,12}
{1,-1,2,5,5, 1,1}
{8,1,2,1,1,1,2}
-5
1
12
1
Returns: 3
منظم
O
Transcribed Image Text:3. {1, -3,2,5, -4,12,12} {1,-1,2,5,5, 1,1} {8,1,2,1,1,1,2} -5 1 12 1 Returns: 3 منظم O
Examples
1.
2.
{0}
{0}
{2}
-5
1
Returns: 0
{0, -6,6}
{0,1,2}
{2,2,2}
-5
1
TST
1
Returns: 2
o
Transcribed Image Text:Examples 1. 2. {0} {0} {2} -5 1 Returns: 0 {0, -6,6} {0,1,2} {2,2,2} -5 1 TST 1 Returns: 2 o
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How would this work if this code was given?

45 00
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class CircleCountry {
// Returns true if point (x,y) is inside circle determined by cx, cy, and r
// and returns false otherwise
public boolean isInside(int x, int y, int cx, int cy, int r) {
// return the result of testing whether the square of the distance
// from (cx, cy) to (x,y) is less than the square of the radius
// fill this in
}
public int least Borders (int[] x, int[] y, int[] r, int x1, int y1, int x2, int y2) {
int crosses = 0;
// loop through all circles
for (int k=0; k < x.length; k+= 1) {
(x2,y2) is inside circle k
// if exactly one of (x1, y1) and
// (specified by x[k], y[k], and r[k]), then increment crosses
// fill this in
}
}
return crosses;
Transcribed Image Text:45 00 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public class CircleCountry { // Returns true if point (x,y) is inside circle determined by cx, cy, and r // and returns false otherwise public boolean isInside(int x, int y, int cx, int cy, int r) { // return the result of testing whether the square of the distance // from (cx, cy) to (x,y) is less than the square of the radius // fill this in } public int least Borders (int[] x, int[] y, int[] r, int x1, int y1, int x2, int y2) { int crosses = 0; // loop through all circles for (int k=0; k < x.length; k+= 1) { (x2,y2) is inside circle k // if exactly one of (x1, y1) and // (specified by x[k], y[k], and r[k]), then increment crosses // fill this in } } return crosses;
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education