鉴于长方体,其具有一个共同的顶点的三个面的面积。我们的任务是找到此平行六面体的所有12个边的长度之和。
在几何形状中,平行六面体是由六个平行四边形形成的三维图形。类似地,它与平行四边形有关,就像立方体与正方形有关或作为长方体涉及矩形一样。矩形平行六面体的图片如下所示。
例子:
Input: 1 1 1
Output: 12
Input: 20 10 50
Output: 68
方法:给定的面积为s1,s2和s3。设a,b和c为具有一个共同顶点的边的长度。在哪里 , , 。很容易找到脸部区域的长度: , , 。答案将是所有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
输出:
120
参考: https : //en.wikipedia.org/wiki/Parallelepiped