Aquí se da un triángulo rectángulo con altura l , base b e hipotenusa h , que inscribe un cuadrado que a su vez inscribe un triángulo reuleaux. La tarea es encontrar el área máxima posible de este triángulo de Reuleaux.
Ejemplos:
Input: l = 5, b = 12, h = 13 Output: 8.77914 Input: l = 3, b = 4, h = 5 Output: 2.07116
Enfoque : sabemos que el lado del cuadrado inscrito dentro de un triángulo rectángulo es a = (l*b)/(l+b) , consulte Área del cuadrado más grande que cabe en un triángulo rectángulo .
Además, en el triángulo de Reuleaux, x = a .
Entonces, x = (l*b)/(l+b) .
Entonces, el área del triángulo de Reuleaux es A = 0.70477*x^2 = 0.70477*((l*b)/(l+b))^2 .
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ Program to find the biggest Reuleaux triangle // inscribed within in a square which in turn // is inscribed within a circle #include <bits/stdc++.h> using namespace std; // Function to find the biggest reuleaux triangle float Area(float l, float b, float h) { // the height or base or hypotenuse // cannot be negative if (l < 0 || b < 0 || h < 0) return -1; // height of the reuleaux triangle float x = (l * b) / (l + b); // area of the reuleaux triangle float A = 0.70477 * pow(x, 2); return A; } // Driver code int main() { float l = 5, b = 12, h = 13; cout << Area(l, b, h) << endl; return 0; }
Java
// Java Program to find the biggest Reuleaux triangle // inscribed within in a square which in turn // is inscribed within a circle import java.util.*; import java.text.DecimalFormat; class GFG { // Function to find the biggest reuleaux triangle static double Area(double l, double b, double h) { // the height or base or hypotenuse // cannot be negative if (l < 0 || b < 0 || h < 0) return -1; // height of the reuleaux triangle double x = (l * b) / (l + b); // area of the reuleaux triangle double A = 0.70477 * Math.pow(x, 2); return A; } // Driver code public static void main(String args[]) { double l = 5, b = 12, h = 13; DecimalFormat df = new DecimalFormat("#,###,##0.00000"); System.out.println(df.format(Area(l, b, h))); } } // This code is contributed by // Shashank_Sharma
Python3
# Python3 Program to find the biggest # Reuleaux triangle inscribed within # in a square which in turn is inscribed # within a circle import math as mt # Function to find the biggest # reuleaux triangle def Area(l, b, h): # the height or base or hypotenuse # cannot be negative if (l < 0 or b < 0 or h < 0): return -1 # height of the reuleaux triangle x = (l * b) /(l + b) # area of the reuleaux triangle A = 0.70477 * pow(x, 2) return A # Driver code l, b, h = 5, 12, 13 print(Area(l, b, h)) # This code is contributed by # Mohit kumar 29
C#
// C# Program to find the biggest Reuleaux triangle // inscribed within in a square which in turn // is inscribed within a circle using System; class GFG { // Function to find the biggest reuleaux triangle static double Area(double l, double b, double h) { // the height or base or hypotenuse // cannot be negative if (l < 0 || b < 0 || h < 0) return -1; // height of the reuleaux triangle double x = (l * b) / (l + b); // area of the reuleaux triangle double A = 0.70477 * Math.Pow(x, 2); return A; } // Driver code public static void Main() { double l = 5, b = 12, h = 13; Console.WriteLine((Area(l, b, h))); } } // This code is contributed by // Mukul Singh
PHP
<?php // PHP Program to find the biggest // Reuleaux triangle inscribed within // in a square which in turn is // inscribed within a circle // Function to find the biggest // reuleaux triangle function Area($l, $b, $h) { // the height or base or hypotenuse // cannot be negative if ($l < 0 or $b < 0 or $h < 0) return -1; // height of the reuleaux triangle $x = ($l * $b) / ($l + $b); // area of the reuleaux triangle $A = 0.70477 * pow($x, 2); return $A; } // Driver code $l = 5; $b = 12; $h = 13; echo Area($l, $b, $h); // This code is contributed by // anuj_67 ?>
Javascript
<script> // Javascript Program to find the biggest Reuleaux triangle // inscribed within in a square which in turn // is inscribed within a circle // Function to find the biggest reuleaux triangle function Area(l,b,h) { // the height or base or hypotenuse // cannot be negative if (l < 0 || b < 0 || h < 0) return -1; // height of the reuleaux triangle let x = (l * b) / (l + b); // area of the reuleaux triangle let A = 0.70477 * Math.pow(x, 2); return A; } // Driver code let l = 5, b = 12, h = 13; document.write( Area(l,b,h).toFixed(5)); // This code contributed by Rajput-Ji </script>
8.77914
Complejidad de tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por IshwarGupta y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA