Dadas dos circunferencias de radios dados, tales que las circunferencias no se tocan, la tarea es encontrar la razón de la distancia entre los centros de las circunferencias y el punto de intersección de dos tangentes comunes directas a las circunferencias.
Ejemplos:
Input: r1 = 4, r2 = 6 Output: 2:3 Input: r1 = 22, r2 = 43 Output: 22:43
Enfoque :
- Sean los radios de los círculos r 1 y r 2 y los centros C 1 y C 2 respectivamente.
- Sea P el punto de intersección de dos tangentes comunes directas a las circunferencias, y A 1 & A 2 el punto de contacto de las tangentes con las circunferencias.
- En el triángulo PC 1 A 1 y el triángulo PC 2 A 2 , el
ángulo C 1 A 1 P = ángulo C 2 A 2 P = 90 grados { la línea que une el centro del círculo con el punto de contacto forma un ángulo de 90 grados con el tangente },
también, ángulo A 1 PC 1 = ángulo A 2 PC 2
entonces, ángulo A 1 C 1 P = ángulo A 2 C 2P
como ángulos son iguales, los triángulos PC 1 A 1 y PC 2 A 2 son similares . - Entonces, debido a la similitud de los triángulos,
C 1 P/C 2 P = C 1 A 1 /C 2 A 2 = r 1 /r 2
La razón de la distancia entre los centros de los círculos y el punto de intersección de dos tangentes comunes directas a los círculos = radio del primer círculo: radio del segundo círculo
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ program to find the ratio of the distance // between the centers of the circles // and the point of intersection of // two direct common tangents to the circles // which do not touch each other #include <bits/stdc++.h> using namespace std; // Function to find the GCD int GCD(int a, int b) { return (b != 0 ? GCD(b, a % b) : a); } // Function to find the ratio void ratiotang(int r1, int r2) { cout << "The ratio is " << r1 / GCD(r1, r2) << " : " << r2 / GCD(r1, r2) << endl; } // Driver code int main() { int r1 = 4, r2 = 6; ratiotang(r1, r2); return 0; }
Java
// Java program to find the ratio of the distance // between the centers of the circles // and the point of intersection of // two direct common tangents to the circles // which do not touch each other class GFG { // Function to find the GCD static int GCD(int a, int b) { return (b != 0 ? GCD(b, a % b) : a); } // Function to find the ratio static void ratiotang(int r1, int r2) { System.out.println("The ratio is " + r1 / GCD(r1, r2) + " : " + r2 / GCD(r1, r2)); } // Driver code public static void main(String args[]) { int r1 = 4, r2 = 6; ratiotang(r1, r2); } } // This code has been contributed by 29AjayKumar
Python3
# Python 3 program to find the ratio # of the distance between the centers # of the circles and the point of intersection # of two direct common tangents to the circles # which do not touch each other # Function to find the GCD from math import gcd # Function to find the ratio def ratiotang(r1, r2): print("The ratio is", int(r1 / gcd(r1, r2)), ":", int(r2 / gcd(r1, r2))) # Driver code if __name__ == '__main__': r1 = 4 r2 = 6 ratiotang(r1, r2) # This code is contributed by # Surendra_Gangwar
C#
// C# program to find the ratio of the distance // between the centers of the circles // and the point of intersection of // two direct common tangents to the circles // which do not touch each other using System; class GFG { // Function to find the GCD static int GCD(int a, int b) { return (b != 0 ? GCD(b, a % b) : a); } // Function to find the ratio static void ratiotang(int r1, int r2) { Console.WriteLine("The ratio is " + r1 / GCD(r1, r2) + " : " + r2 / GCD(r1, r2)); } // Driver code public static void Main(String[] args) { int r1 = 4, r2 = 6; ratiotang(r1, r2); } } // This code contributed by Rajput-Ji
PHP
<?php // PHP program to find the ratio of the distance // between the centers of the circles // and the point of intersection of // two direct common tangents to the circles // which do not touch each other // Function to find the GCD function GCD($a, $b) { return ($b != 0 ? GCD($b, $a % $b) : $a); } // Function to find the ratio function ratiotang($r1, $r2) { echo "The ratio is ", $r1 / GCD($r1, $r2), " : ", $r2 / GCD($r1, $r2) ; } // Driver code $r1 = 4; $r2 = 6; ratiotang($r1, $r2); // This code is contributed by AnkitRai01 ?>
Javascript
<script> // javascript program to find the ratio of the distance // between the centers of the circles // and the point of intersection of // two direct common tangents to the circles // which do not touch each other // Function to find the GCD function GCD(a , b) { return (b != 0 ? GCD(b, a % b) : a); } // Function to find the ratio function ratiotang(r1 , r2) { document.write("The ratio is " + r1 / GCD(r1, r2) + " : " + r2 / GCD(r1, r2)); } // Driver code var r1 = 4, r2 = 6; ratiotang(r1, r2); // This code is contributed by Princi Singh </script>
The ratio is 2 : 3
Complejidad del tiempo: O(log(min(a, b)))
Espacio auxiliar: O(log(min(a, b)))
Publicación traducida automáticamente
Artículo escrito por IshwarGupta y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA