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 ...
随机推荐
- 一台服务器搭载两个tomcat项目
之前下载的mysql 在官网是有 历史库的 如果现在一台机器上已经部署了一个tomcat服务,无论这个tomcat是否已经注册为服务了,或者没有注册windows服务,或者注册了,都没关系.都可以采 ...
- Hibernate对象映射类型
Hibernate understands both the Java and JDBC representations of application data. The ability to rea ...
- c# 多线程创建 ---简单
Thread t = new Thread(new ParameterizedThreadStart(UploadCard)); t.IsBackground = false;//后台线程 前台线程 ...
- MSP430x1_4_6x之问题总结
01:MSP430端口上电复位的初始值是不确定的:所以使用是都要初始化:比如加下面的语句或者加你使用的端口就行了: /*下面六行程序关闭所有的IO口*/ P1DIR = 0XFF;P1OUT ...
- hadoop的RPC通信
RPC(remote procedure call)远程调用 不同的Java进程间的对象方法调用 一方称作服务端(server),一方称作客户端(client) server端提供对象,供客户端调用, ...
- 2013年8月份第1周51Aspx源码发布详情
校企工作室OA源码 2013-8-9 [VS2010]源码描述:主要模块及系统管理功能说明:一.考勤功能模块:考勤分成三个功能,显示签到功能,查询功能,管理功能.1.签到功能分析:在签到功能中,我们 ...
- hdu4417 划分树+二分
//Accepted 14796 KB 453 ms //划分树 //把查询的次数m打成n,也是醉了一晚上!!! //二分l--r区间第k大的数和h比较 #include <cstdio> ...
- Javascript 的类型转换之减号
专职写JS已经有一个月了(对,没错就是一个月),从2014年11月24实习开始到今的2月份,我做的工作一直都是切图,另外跟着老板学产品,现在我一听到切图两字,我就想吐...所以我找了一份专职写JS的工 ...
- c规范(2)
一:对齐 1 程序的分界符' {'和' }'应独占一行并且位于同一列,同时与引用它们的语句左对齐. 2 { }之内的代码块在' {'右边数格处左对齐. 二:注释 注释通常用于:( 1)版本.版权声明 ...
- (转)关于java和web项目中的相对路径问题
原文:http://blog.csdn.net/yethyeth/article/details/1623283 关于java和web项目中的相对路径问题 分类: java 2007-05-23 22 ...