Codeforces Round #138 (Div. 2) A. Parallelepiped
2 seconds
256 megabytes
standard input
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.
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.
Print a single number — the sum of all edges of the parallelepiped.
- 1 1 1
- 12
- 4 6 6
- 28
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的更多相关文章
- Codeforces Round #138 (Div. 2)
A. Parallelepiped 枚举其中一边,计算其他两条边. B. Array 模拟. C. Bracket Sequence 栈. D. Two Strings \(pre[i]\)表示第i个 ...
- Codeforces Round #138 (Div. 2) ACBDE
A.Parallelepiped 题意:给一个六面体三面的面积,求12条边的长度和. 题解:因为都是整数,设边长分别为a,b,c,面积为xyz,那么可设x=a*b,y=b*c,z=c*a,简单解方程就 ...
- Codeforces Round #138 (Div. 1)
A 记得以前做过 当时好像没做对 就是找个子串 满足括号的匹配 []最多的 开两个栈模拟 标记下就行 #include <iostream> #include<cstring> ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
随机推荐
- 2013 ACM/ICPC 亚洲区 杭州站
题目链接 2013杭州区域赛 Problem A Problem B 这题我用的是SPFA+ mask dp 首先跑5次SPFA: 1次是求出每个起点和其他所有点的最短距离 4次是求出每个输入的点和 ...
- qt使用
1安装qt软件(.run文件) . chmod 777 qt.....run ./qt...run或sudo ./qt...run(安装目录不一样) 2.sudo gedit .bashrc添加以下内 ...
- mybatis 源码学习(一)配置文件初始化
mybatis是项目中常用到的持久层框架,今天我们学习下mybatis,随便找一个例子可以看到通过读取配置文件建立SqlSessionFactory,然后在build拿到关键的sqlsession,这 ...
- SSM整合案例
使用IDEA整合SSM spring核心配置文件:beans_core.xml/applicationContext.xml <?xml version="1.0" enco ...
- C#深入学习:泛型修饰符in,out、逆变委托类型和协变委托类型
在C#中,存在两个泛型修饰符:in和out,他们分别对应逆变委托和协变委托. 我们知道,在C#中要想将一个泛型对象转换为另一个泛型对象时,必须要将一个泛型对象拆箱,对元素进行显式或隐式转换后重新装箱. ...
- Java出现错误“Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )”的问题分析
若出现:Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )这样的问题,一般是转义字符的问题,下 ...
- JS里面的call, apply以及bind
参考了这篇文章:http://www.tuicool.com/articles/EVF3Eb 给几个例子 function add(a,b) { alert(a+b); } function sub( ...
- css3 - target
通过CSS3伪元素target,我们可以实现拉风琴 源码 <!DOCTYPE HTML> <html lang="en-US"> <head> ...
- CTP报单状态 OrderStatus全部状态
- PHP_EOL是什么意思?
PHP_EOL 代表php的换行符, 这个变量会根据平台而变, 在windows下会是/r/n, 在linux下是/n, 在mac下是/r 文章来源:刘俊涛的博客 地址:h ...