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 ...
随机推荐
- BZOJ——2134: 单选错位
http://www.lydsy.com/JudgeOnline/problem.php?id=2134 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: ...
- Leetcode 数组问题3:旋转数组
问题描述: 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数. 示例 : 输入A数组: [1,2,3,4,5,6,7] 和 k = 3 输出: [5,6,7,1,2,3,4] 解释 ...
- Java中获取ServletContext的方法
Servlet: this.getServletContext() this.getServletConfig().getServletContext() request.getSession().g ...
- iOS应用崩溃日志揭秘
这篇文章还可以在这里找到 英语 Learn how to make sense of crash logs! 本文作者是 Soheil Moayedi Azarpour, 他是一名独立iOS开发者. ...
- cocos2d-x step by step(1) First Blood
下了cocos2d-x 源码,开搞! 首先,笔者本身 1) 5年没有摸过c++了 2) 没用过cocos2d-x 3) 有强烈的求知欲望(这条每个简历个人介绍不都这么写么, ...
- mac异常删除管理员账户恢复操作
重新启动电脑,同时按下command+s键进入命令行方式 待系统加载完成后顺序输入以下命令: /sbin/mount -uaw rm var/db/.applesetupdone reboot 待系统 ...
- Mysql多线程性能测试工具sysbench 安装、使用和测试
From:http://www.cnblogs.com/zhoujinyi/archive/2013/04/19/3029134.html 摘要: sysbench是一个开源的.模块化的.跨 ...
- Java反射及其在Android中的应用学习总结
一. Java反射机制 Reflection 是Java被视为动态(或准动态)语言的一个关键性质.这个机制同意程序在执行时透过Reflection APIs取得不论什么一个已知名称的class的内部信 ...
- Qt在线讲座之QML脚本书写规范
时间:2016年3月1日晚7:30 在线讲座:http://qtdream.com主页处就可以收看直播(详见主页提示) 參与对象:对Qt跨平台开发框架感兴趣的朋友们.当然了,假设你是大牛.也可以旁听一 ...
- JSP学习笔记(一)
JSP是基于JAVA语言的,区分大小写,HTML不区分大小写 如何建立Web服务目录? 1.在Webapps下面建立Web服务目录MYJSP 在Webapps下面新建文件夹MYJSP,将写好的jsp文 ...