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", n);
}
return 0;
}

Codeforces Round #138 (Div. 2) A. Parallelepiped的更多相关文章

  1. Codeforces Round #138 (Div. 2)

    A. Parallelepiped 枚举其中一边,计算其他两条边. B. Array 模拟. C. Bracket Sequence 栈. D. Two Strings \(pre[i]\)表示第i个 ...

  2. Codeforces Round #138 (Div. 2) ACBDE

    A.Parallelepiped 题意:给一个六面体三面的面积,求12条边的长度和. 题解:因为都是整数,设边长分别为a,b,c,面积为xyz,那么可设x=a*b,y=b*c,z=c*a,简单解方程就 ...

  3. Codeforces Round #138 (Div. 1)

    A 记得以前做过 当时好像没做对 就是找个子串 满足括号的匹配 []最多的 开两个栈模拟 标记下就行 #include <iostream> #include<cstring> ...

  4. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

随机推荐

  1. 洛谷——P2912 [USACO08OCT]牧场散步Pasture Walking(lca)

    题目描述 The N cows (2 <= N <= 1,000) conveniently numbered 1..N are grazing among the N pastures ...

  2. 访问权限修饰符Protected专题

    上图描述:A类在a包下,m()方法被protected修饰 上图描述:B类也在a包下,B类是A类的子类. 解析:B类和A类是同包类,B类是A类的子类,因此b对象可以调用m()方法. 上图描述:C类也在 ...

  3. jsonp _____跨域请求实现

    请求如下: $.ajax({ type: "GET", async:false, url: "http://127.0.0.1:8080/Cross-site-reque ...

  4. Linux下Shell的快捷键(转)

    下述所有命令在Linux/Unix的shell下有效,这里以bash为主.如有出入,以你自己的服务器为准.本文所指的Linux主要指RHEL/CentOS,Unix指的是FreeBSD,这也是Unix ...

  5. 转载cookie理解

    本文转自https://www.cnblogs.com/dojo-lzz/p/5580301.html 服务器端像客户端发送Cookie是通过HTTP响应报文实现的,在Set-Cookie中设置需要像 ...

  6. 【hibernate】唯一约束 注解

    唯一约束注解 单列约束和联合约束 分别如下 @Table( uniqueConstraints = { @UniqueConstraint(columnNames = "uid") ...

  7. 【UI】为项目添加类似于淘宝筛选列表勾选的ui-choose

    jQuery下载的地址:http://www.htmleaf.com/jQuery/Form/201512182916.html GitHub地址:https://github.com/wangxin ...

  8. nexus启动报错-----&gt;错误 1067: 进程意外终止。

    1.今天启动nexus报错: 2.错误信息 错误 1067: 进程意外终止. 3.检查发现我之前把jdk升级了. 然而nexus之前指定的jdk将不再生效. 4.解决的方法 找到nexus安装文件夹 ...

  9. construct-binary-tree-from-preorder-and-inorder-traversal——前序和中序求二叉树

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:  You may assume tha ...

  10. Triangle 三角形——找出三角形中从上至下和最小的路

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...