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. Eventbus 使用方法和原理分析

    对于 Eventbus ,相信很多 Android 小伙伴都用到过. 1.创建事件实体类 所谓的事件实体类,就是传递的事件,一个组件向另一个组件发送的信息可以储存在一个类中,该类就是一个事件,会被 E ...

  2. luogu U10783 名字被和谐了

    链接 https://www.luogu.org/problem/show?pid=U10783 题目背景 众所周知,我们称g是a的约数,当且仅当g是正数且a mod g = 0. 众所周知,若g既是 ...

  3. POI2004

    11th Polish Olympiad in Informatics(POI2004) <br > 填坑计划第二弹......把这个没填完的坑搬过来啦~ 上次勉强填完NEERC的坑... ...

  4. JavaScript世界万物诞生记

    作者:manxisuo链接:https://zhuanlan.zhihu.com/p/22989691来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 一. 无中生有 起 ...

  5. scrapy 启动失败,scrapy startproject test 出错 'module' object has no attribute 'OP_NO_TLSv1_1

    你先看看 pip install scrapy需要的 pyopenssl  twisted  等和你安装的版本一样么  我的就是因为TWist 版本高于  需要的 用pip install twist ...

  6. Dubbo简介及实例

    节点角色说明: Ø  Provider: 暴露服务的服务提供方. Ø  Consumer: 调用远程服务的服务消费方. Ø  Registry: 服务注册与发现的注册中心. Ø  Monitor: 统 ...

  7. 怎么在SQL查询的结果里加行号?

    怎么在SQL查询的结果里加行号? 学习了:https://zhidao.baidu.com/question/91188037.html mysql : ) as rowNo From a, () ) ...

  8. lua——基础语法

    -- test lua: for learning lua grammar -- line comment --[[ block comment ]]-- -- print hello world p ...

  9. mysql 数据迁移时遇到 外键限制

    禁用外键约束    SET FOREIGN_KEY_CHECKS=0; ......数据迁移........ 启动外键约束    SET FOREIGN_KEY_CHECKS=1;

  10. angular - 新建项目 - 2

    ng new testNg 新建项目后,从网络上拉取模板(最后缓存下来,我们下次创建项目的时间将会减少80%) 安装过程中,需要我们提供Git账号和姓名 最后,我们进入 useNg 然后,启动服务器 ...