Advertisement
roronoa

circles intersection

Jun 18th, 2020
2,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Auto-generated code below aims at helping you parse
  3.  * the standard input according to the problem statement.
  4.  **/
  5. let intersection = (C1, C2) => {
  6.     let distance = (C1.x - C2.x)**2 + (C1.y - C2.y)**2
  7.     return distance <= (C1.rayon + C2.rayon)**2
  8. }
  9. const n = parseInt(readline());
  10. let circles = []
  11. for (let i = 0; i < n; i++) {
  12.     var inputs = readline().split(' ');
  13.     const x = parseFloat(inputs[0]);
  14.     const y = parseFloat(inputs[1]);
  15.     circles.push({x, y, rayon: 0})
  16. }
  17. let count = 0
  18.  
  19. while(1) {
  20.     let c = 0
  21.     for(let i = 0; i < circles.length; i++) {
  22.         for(let j = 0; j < circles.length; j++){
  23.             if(i != j) {
  24.                 if(intersection(circles[i], circles[j])) {
  25.                     print(count)
  26.                     c++
  27.                
  28.                 }
  29.             }
  30.         }
  31.     }
  32.     for(let i = 0; i < circles.length; i++) {
  33.         circles[i].rayon++
  34.     }
  35.     count++
  36. }
  37. // Write an answer using console.log()
  38. // To debug: console.error('Debug messages...');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement