📜  任何长方体的所有 12 条边的长度之和

📅  最后修改于: 2021-10-23 08:45:26             🧑  作者: Mango

鉴于长方体,其具有一个共同的顶点的三个面的面积。我们的任务是找到这个平行六面体的所有 12 条边长度
在几何学中,平行六面体是由六个平行四边形构成的三维图形。以此类推,它涉及平行四边形,就像立方体涉及正方形或长方体涉及矩形一样。长方体的图片如下所示。

例子:

Input: 1 1 1 
Output: 12

Input: 20 10 50
Output: 68

方法:给定的区域是 s1, s2 和 s3 。设 a、b 和 c 是具有一个公共顶点的边的长度。在哪里s1 = a * b , s2 = b * c , s3 = c * a .根据面部区域很容易找到长度: a = \sqrt{s1s3/s2} , b = \sqrt{s1s2/s3} , c = \sqrt{s2s3/s1} .答案将是所有 4 条边的总和,有 4 条边的长度等于 a、b 和 c。
在第一个例子中,给定的面积 s1 = 1,s2 = 1 和 s3 = 1。所以使用上述方法,a、b、c 的值将是 1。所以所有 12 条边的长度之和将是 4 * 3 = 12。
下面是上述方法的实现:

C++
// C++ program to illustrate
// the above problem
#include 
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


Javascript


输出:
120

参考: https : //en.wikipedia.org/wiki/Parallelepiped