uva 1333 - Model Rocket Height(几何)
2015-08-31 23:06
411 查看
题目链接:uva 1333 - Model Rocket Height
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
const double pi = 4 * atan(1);
inline int dcmp(double x) { if (fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; }
double toRad(double x) { return x / 180.0 * pi; }
int main () {
double d, h, a, b, c;
scanf("%lf%lf", &d, &h);
while (scanf("%lf%lf%lf", &a, &b, &c) == 3) {
if (dcmp(a) == 0 && dcmp(b) == 0 && dcmp(c) == 0) break;
a = tan(toRad(a)), b = tan(toRad(b)), c = tan(toRad(c));
double ans = d * sqrt(2/(1/a/a+1/c/c-2/b/b)) + h;
printf("%d\n", (int)(ans + 0.5));
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-9;
const double pi = 4 * atan(1);
inline int dcmp(double x) { if (fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; }
double toRad(double x) { return x / 180.0 * pi; }
int main () {
double d, h, a, b, c;
scanf("%lf%lf", &d, &h);
while (scanf("%lf%lf%lf", &a, &b, &c) == 3) {
if (dcmp(a) == 0 && dcmp(b) == 0 && dcmp(c) == 0) break;
a = tan(toRad(a)), b = tan(toRad(b)), c = tan(toRad(c));
double ans = d * sqrt(2/(1/a/a+1/c/c-2/b/b)) + h;
printf("%d\n", (int)(ans + 0.5));
}
return 0;
}
相关文章推荐
- 面向对象
- 8-31号19题作业
- 2014ACM-ICPC亚洲区域西安赛区 G题 / GYM 100548 G
- iOS 面试中的高频题目
- POJ-1797 Heavy Transportation
- VS中修改站点运行方式(集成 Or 经典)
- react.js 从零开始(三)JSX 语法及特点介绍
- spark
- SPI小节
- uva 1373 - How I Wonder What You Are!(几何)
- Linux之文本编辑器VIM
- 分享作为程序猿的快乐
- [C++11 并发编程] 16 在期望中保存异常
- 3D GAME PROGRAMMING WITH DIRECTX11 (1)
- Java多线程之线程生命周期以及线程各个时期的状态
- 人人网用户信息爬虫
- 分享作为程序猿的快乐
- [Effective Java 读书笔记] 第三章 对所有对象都通用的方法 第八 ---- 九条
- java 8 JVM性能优化
- Android控件之SlidingDrawer(滑动式抽屉)详解与实例