Mayor Triángulo de Reuleaux inscrito en un cuadrado inscrito en un semicírculo

Aquí se da un semicírculo de radio r 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 : x = 5  
Output : 14.0954

Input : x = 8
Output : 36.0842

Planteamiento : Sabemos que el lado del cuadrado inscrito en un semicírculo es a = 2r/√5 . (Consulte aquí)
Además, en el triángulo de Reuleaux, x = a
Entonces, x = 2*r/√5 
Entonces, Área del Triángulo de Reuleaux
 

A = 0.70477*x^2 = 0.70477*(r^2/5)

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 semicircle
 
#include <bits/stdc++.h>
using namespace std;
 
// Function to find the biggest reuleaux triangle
float Area(float r)
{
 
    // radius cannot be negative
    if (r < 0)
        return -1;
 
    // height of the reuleaux triangle
    float x = (2 * r) / sqrt(5);
 
    // area of the reuleaux triangle
    float A = 0.70477 * pow(x, 2);
 
    return A;
}
 
// Driver code
int main()
{
    float r = 5;
    cout << Area(r) << endl;
 
    return 0;
}

Java

// Java Program to find the biggest
// Reuleaux triangle inscribed within
// in a square which in turn is
// inscribed within a semicircle
import java.lang.Math;
 
class GFG
{
 
// Function to find the biggest reuleaux triangle
static float Area(float r)
{
 
    // radius cannot be negative
    if (r < 0)
        return -1;
 
    // height of the reuleaux triangle
    float x = (2 * r) /(float)(Math.sqrt(5));
 
    // area of the reuleaux triangle
    float A = 0.70477f *(float)(Math.pow(x, 2));
 
    return A;
}
 
// Driver code
public static void main(String[] args)
{
    float r = 5;
    System.out.println(Area(r));
}
}
 
// This code is contributed by Mukul Singh.

Python3

# Python3 Program to find the biggest
# Reuleaux triangle inscribed within
# in a square which in turn is inscribed
# within a semicircle
import math as mt
 
# Function to find the biggest
# reuleaux triangle
def Area(r):
 
    # radius cannot be negative
    if (r < 0):
        return -1
 
    # height of the reuleaux triangle
    x = (2 * r) / mt.sqrt(5)
 
    # area of the reuleaux triangle
    A = 0.70477 * pow(x, 2)
 
    return A
 
# Driver code
r = 5
print(Area(r))
 
# 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 semicircle
using System;
 
class GFG
{
 
// Function to find the biggest reuleaux triangle
static double Area(double r)
{
 
    // radius cannot be negative
    if (r < 0)
        return -1;
 
    // height of the reuleaux triangle
    double x = (2 * r) / (double)(Math.Sqrt(5));
 
    // area of the reuleaux triangle
    double A = 0.70477  * (double)(Math.Pow(x, 2));
 
    return A;
}
 
// Driver code
public static void Main()
{
    double r = 5;
    Console.WriteLine(Area(r));
}
}
 
// This code is contributed by chandan_jnu

PHP

<?php
// PHP Program to find the biggest Reuleaux
// triangle inscribed within in a square
// which in turn is inscribed within a semicircle
 
// Function to find the biggest
// reuleaux triangle
function Area($r)
{
 
    // radius cannot be negative
    if ($r < 0)
        return -1;
 
    // height of the reuleaux triangle
    $x = (2 * $r) / sqrt(5);
 
    // area of the reuleaux triangle
    $A = 0.70477 * pow($x, 2);
 
    return $A ;
}
 
// Driver code
$r = 5;
 
echo Area($r);
     
// This code is contributed by Ryuga
?>

Javascript

<script>
// javascript Program to find the biggest
// Reuleaux triangle inscribed within
// in a square which in turn is
// inscribed within a semicircle
 
// Function to find the biggest reuleaux triangle
function Area(r)
{
 
    // radius cannot be negative
    if (r < 0)
        return -1;
 
    // height of the reuleaux triangle
    var x = (2 * r) /(Math.sqrt(5));
 
    // area of the reuleaux triangle
    var A = 0.70477 *(Math.pow(x, 2));
    return A;
}
 
// Driver code
var r = 5;
document.write(Area(r).toFixed(4));
 
 
// This code is contributed by Princi Singh
</script>
Producción: 

14.0954

 

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

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *