Suma de las longitudes de las 12 aristas de cualquier paralelepípedo rectangular

Dada el área de tres caras del paralelepípedo rectangular que tiene un vértice común. Nuestra tarea es encontrar la suma de las longitudes de las 12 aristas de este paralelepípedo.
En geometría, un paralelepípedo es una figura tridimensional formada por seis paralelogramos. Por analogía, se relaciona con un paralelogramo tal como un cubo se relaciona con un cuadrado o como un paralelepípedo con un rectángulo. A continuación se muestra una imagen de un paralelepípedo rectangular.
 

Ejemplos: 
 

Input: 1 1 1 
Output: 12

Input: 20 10 50
Output: 68

Aproximación: Las áreas dadas son s1, s2 y s3. Sean a, b y c las longitudes de los lados que tienen un vértice común. donde  s1 = a * b s2 = b * c s3 = c * a . Es fácil encontrar la longitud en términos de áreas de caras:  a = \sqrt{s1s3/s2} b = \sqrt{s1s2/s3} c = \sqrt{s2s3/s1} . La respuesta será la suma de los 4 lados, hay cuatro lados que tienen longitudes iguales a a, b y c.
En el primer ejemplo, el área dada s1 = 1, s2 = 1 y s3 ​​= 1. Entonces, con el enfoque anterior, el valor de a, b, c resultará ser 1. Entonces, la suma de la longitud de los 12 bordes será 4 * 3 = 12.
A continuación se muestra la implementación del enfoque anterior: 
 

C++

// C++ program to illustrate
// the above problem
#include <bits/stdc++.h>
using namespace std;
 
// function to find the sum of
// all the edges of parallelepiped
double findEdges(double s1, double s2, double s3)
{
    // to calculate the length of one edge
    double a = sqrt(s1 * s2 / s3);
    double b = sqrt(s3 * s1 / s2);
    double c = sqrt(s3 * s2 / s1);
 
    // sum of all the edges of one side
    double sum = a + b + c;
 
    // net sum will be equal to the
    // summation of edges of all the sides
    return 4 * sum;
}
 
// Driver code
int main()
{
    // initialize the area of three
    // faces which has a common vertex
    double s1, s2, s3;
    s1 = 65, s2 = 156, s3 = 60;
 
    cout << findEdges(s1, s2, s3);
 
    return 0;
}

Java

// Java program to illustrate
// the above problem
 
import java.io.*;
 
class GFG {
   
// function to find the sum of
// all the edges of parallelepiped
static double findEdges(double s1, double s2, double s3)
{
    // to calculate the length of one edge
    double a = Math.sqrt(s1 * s2 / s3);
    double b = Math.sqrt(s3 * s1 / s2);
    double c = Math.sqrt(s3 * s2 / s1);
 
    // sum of all the edges of one side
    double sum = a + b + c;
 
    // net sum will be equal to the
    // summation of edges of all the sides
    return 4 * sum;
}
 
       // Driver code
 
    public static void main (String[] args) {
            // initialize the area of three
    // faces which has a common vertex
    double s1, s2, s3;
    s1 = 65; s2 = 156; s3 = 60;
 
    System.out.print(findEdges(s1, s2, s3));
    }
}
 
 
// this code is contributed by anuj_67..

Python3

import math
 
# Python3 program to illustrate
# the above problem
 
# function to find the sum of
# all the edges of parallelepiped
def findEdges(s1, s2, s3):
 
    # to calculate the length of one edge
    a = math.sqrt(s1 * s2 / s3)
    b = math.sqrt(s3 * s1 / s2)
    c = math.sqrt(s3 * s2 / s1)
 
    # sum of all the edges of one side
    sum = a + b + c
 
    # net sum will be equal to the
    # summation of edges of all the sides
    return 4 * sum
 
 
# Driver code
if __name__=='__main__':
     
# initialize the area of three
# faces which has a common vertex
    s1 = 65
    s2 = 156
    s3 = 60
 
    print(int(findEdges(s1, s2, s3)))
         
# This code is contributed by
# Shivi_Aggarwal

C#

// C# program to illustrate
// the above problem
using System;
 
public class GFG{
     
// function to find the sum of
// all the edges of parallelepiped
static double findEdges(double s1, double s2, double s3)
{
    // to calculate the length of one edge
    double a = Math.Sqrt(s1 * s2 / s3);
    double b = Math.Sqrt(s3 * s1 / s2);
    double c = Math.Sqrt(s3 * s2 / s1);
 
    // sum of all the edges of one side
    double sum = a + b + c;
 
    // net sum will be equal to the
    // summation of edges of all the sides
    return 4 * sum;
}
 
// Driver code
 
    static public void Main (){
    // initialize the area of three
    // faces which has a common vertex
    double s1, s2, s3;
    s1 = 65; s2 = 156; s3 = 60;
 
    Console.WriteLine(findEdges(s1, s2, s3));
    }
}
 
 
// This code is contributed by anuj_67..

PHP

<?php
// PHP program to illustrate
// the above problem
 
// function to find the sum of
// all the edges of parallelepiped
function findEdges($s1, $s2, $s3)
{
    // to calculate the length of one edge
    $a = sqrt($s1 * $s2 / $s3);
    $b = sqrt($s3 * $s1 / $s2);
    $c = sqrt($s3 * $s2 / $s1);
 
    // sum of all the edges of one side
    $sum = $a + $b + $c;
 
    // net sum will be equal to the
    // summation of edges of all the sides
    return 4 * $sum;
}
 
// Driver code
 
// initialize the area of three
// faces which has a common vertex
$s1; $s2; $s3;
$s1 = 65; $s2 = 156; $s3 = 60;
 
echo findEdges($s1, $s2, $s3);
 
// This code is contributed by Shashank
?>

Javascript

<script>
    // Javascript program to illustrate the above problem
     
    // function to find the sum of
    // all the edges of parallelepiped
    function findEdges(s1, s2, s3)
    {
        // to calculate the length of one edge
        let a = Math.sqrt(s1 * s2 / s3);
        let b = Math.sqrt(s3 * s1 / s2);
        let c = Math.sqrt(s3 * s2 / s1);
 
        // sum of all the edges of one side
        let sum = a + b + c;
 
        // net sum will be equal to the
        // summation of edges of all the sides
        return 4 * sum;
    }
     
    // initialize the area of three
    // faces which has a common vertex
    let s1, s2, s3;
    s1 = 65; s2 = 156; s3 = 60;
   
    document.write(findEdges(s1, s2, s3));
 
</script>
Producción: 

120

 

Referencia: https://en.wikipedia.org/wiki/Parallelepiped
 

Publicación traducida automáticamente

Artículo escrito por SrijaDe 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 *