ZOJ 1241 Geometry Made Simple
/*
Mathematics can be so easy when you have a computer. Consider the following example. You probably know that in a right-angled triangle, the length of the three sides a, b, c (where c is the longest side, called the hypotenuse) satisfy the relation a*a+b*b=c*c. This is called Pythagora’s Law.
Here we consider the problem of computing the length of the third side, if two are given.
Input
The input contains the descriptions of several triangles. Each description consists of a line containing three integers a, b and c, giving the lengths of the respective sides of a right-angled triangle. Exactly one of the three numbers is equal to -1 (the ‘unknown’ side), the others are positive (the ‘given’ sides).
A description having a=b=c=0 terminates the input.
Output
For each triangle description in the input, first output the number of the triangle, as shown in the sample output. Then print “Impossible.” if there is no right-angled triangle, that has the ‘given’ side lengths. Otherwise output the length of the ‘unknown’ side in the format “s = l”, where s is the name of the unknown side (a, b or c), and l is its length. l must be printed exact to three digits to the right of the decimal point.
Print a blank line after each test case.
Sample Input
3 4 -1
-1 2 7
5 -1 3
0 0 0
Sample Output
Triangle #1
c = 5.000
Triangle #2
a = 6.708
Triangle #3
Impossible.
*/
#include<stdio.h>
#include<math.h> int main(){
double a,b,c;
int n=0;
while(scanf("%lf%lf%lf",&a,&b,&c)){
if(a==0&&b==0&&c==0)
break;
n++;
if (c==-1)
{
c=sqrt(a*a+b*b);
printf("Triangle #%d\n",n);
printf("c = %.3lf\n",c);
}
else
if (a==-1)
{
a=sqrt(c*c-b*b);
printf("Triangle #%d\n",n);
if (c>b)
printf("a = %.3lf\n",a);
else
printf("Impossible.\n");
}
else
if (b==-1)
{
b=sqrt(c*c-a*a);
printf("Triangle #%d\n",n);
if (c>a)
printf("b = %.3lf\n",b);
else
printf("Impossible.\n");
}
printf("\n"); } return 0;
}
ZOJ 1241 Geometry Made Simple的更多相关文章
- ZOJ Problem Set - 1241 Geometry Made Simple
水题不解释 #include <stdio.h> #include <math.h> int main() { ,flag=; double a,b,c; while(scan ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- MySQL所有函数及操作符
参考:Function and Operator Reference Name Description ABS() Return the absolute value ACOS() Return th ...
- arcgis地图服务之 identify 服务
arcgis地图服务之 identify 服务 在近期的一次开发过程中,利用IdentityTask工具查询图层的时候,请求的参数中ImageDisplay的参数出现了错误,导致查询直接不能执行,百度 ...
- 翻译:探索GLSL-用几何着色器(着色器库)实现法线可视化
翻译:探索GLSL-用几何着色器(着色器库)实现法线可视化 翻译自: Exploring GLSL – Normal Visualizer with Geometry Shaders (Shader ...
- Extensions for Spatial Data
http://dev.mysql.com/worklog/task/?spm=5176.100239.blogcont4270.8.j3asa7&id=6609 前文: 这两天因为项目原因看了 ...
- mysql 函数表
Name Description ABS() Return the absolute value ACOS() Return the arc cosine ADDDATE() Add time val ...
- cvpr2015papers
@http://www-cs-faculty.stanford.edu/people/karpathy/cvpr2015papers/ CVPR 2015 papers (in nicer forma ...
随机推荐
- Android窃取用户信息新思路
0×01 我们能得到哪些android手机上的app敏感信息手机上的app敏感信息◦通讯录,通讯记录,短信◦各种app的帐号密码,输入信息资料等◦各种影音资料,照片资料◦等等0×02 我们有哪些方法 ...
- HDU 5451 广义斐波那契数列
这道题目可以先转化: 令f(1) = 5+2√6 f(2) = f(1)*(5+2√6) ... f(n) = f(n-1)*(5+2√6) f(n) = f(n-1)*(10-(5-2√6)) = ...
- oracle安装后登录
运行 sqlplus回车 longon as sysdba回车 回车 这样就可以登录了. SQL>create user username identified by password; SQL ...
- ios开发逆向传值的几种方法整理
第一种:代理传值 第二个控制器: @protocol WJSecondViewControllerDelegate <NSObject> - (void)changeText:(NSStr ...
- OpenCV坐标体系的初步认识
实验基础 本次实验通过一个简短的例子,主要来说明下面4个问题: 1. 坐标体系中的零点坐标为图片的左上角,X轴为图像矩形的上面那条水平线:Y轴为图像矩形左边的那条垂直线.该坐标体系在诸如结构体Mat, ...
- 谁说固态硬盘没容量?4TB诞生、明年8TB!
固态硬盘已经逐渐取代机械硬盘成为很多用户的首选,但唯一欠缺的就是容量,或者说单位容量的价格,但是如今,机械硬盘的容量提升举步维艰,固态硬盘却在突飞猛进. 近日,SanDisk就宣布了全球第一款容量高达 ...
- MongoDB数据访问[C#]附源码下载(查询增删改) 转载
安装完MongoDBhttp://localhost:28017/监测是否成功! vs 2008 C# MongoDB 源代码下载地址:http://download.csdn.net/source/ ...
- App右上角数字
IOS7: UIApplication *app = [UIApplication sharedApplication]; // 应用程序右上角数字 app.applicationIconBadgeN ...
- 使用hadoop multipleOutputs对输出结果进行不一样的组织
MapReduce job中,可以使用FileInputFormat和FileOutputFormat来对输入路径和输出路径来进行设置.在输出目录中,框架自己会自动对输出文件进行命名和组织,如:par ...
- yii2 sphinx Ajax搜索分页 关键词的缓存
控制器层 <?php namespace frontend\controllers; use Yii; use yii\web\Controller; //use frontend\models ...