zoukankan      html  css  js  c++  java
  • Codeforces Round #138 (Div. 2) A. Parallelepiped

    A. Parallelepiped
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.

    Input

    The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive ( > 0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.

    Output

    Print a single number — the sum of all edges of the parallelepiped.

    Sample test(s)
    Input
    1 1 1
    Output
    12
    Input
    4 6 6
    Output
    28
    Note

    In the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3.

         题目和算法分析:本题给出 一个长方体的 有“共同顶点”的3个面的面积 ,请你计算出 该长方体的12条棱的长度之和。

                               假设:3个面的面积分别是:x, y, z;  长宽高分别是:a, b, c;

                                       --->(1) a*b=x;   (2) a*c=y;  (3) b*c=z; 

                                       --->先让(1)与(2) 式 相除, --->  b/c = x/y ;  将此式与(3)式 联立 :---> c^2=(z*y)/x;

                                        同理可得: a^2=(x*y)/z;     b^2=(x*z)/y;

                                        然后用数学函数sqrt() 开方一下,计算出a, b, c, 再将它们加起来的和乘以4 输出就可以了!

         

    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <math.h>
    #include <string.h>
    #include <algorithm>
    
    using namespace std;
    
    
    int main()
    {
        int x, y, z;
        int a, b, c;
    
        while(scanf("%d %d %d", &x, &y, &z)!=EOF)
        {
            a=sqrt((y*x)/z);
            b=sqrt( (x*z)/y );
            c=sqrt( (z*y)/x);
            int n;
            n=(a+b+c)*4;
            printf("%d
    ", n);
        }
        return 0;
    }
    

              

  • 相关阅读:
    Java 将数字转为16进制,然后转为字符串类型 将空格去掉。终结版
    Java 将数字转为16进制,然后转为字符串类型
    Java 数组转字符
    Apple Reject
    NSInternalInconsistencyException
    svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法
    CSS伪类选择器 奇偶匹配nth-child(even)
    常用css代码(scss mixin)
    织梦网站给栏目添加自定义字段图文详解
    css怎么解决表格边框线重复问题
  • 原文地址:https://www.cnblogs.com/yspworld/p/4052566.html
Copyright © 2011-2022 走看看