/*
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的更多相关文章

  1. ZOJ Problem Set - 1241 Geometry Made Simple

    水题不解释 #include <stdio.h> #include <math.h> int main() { ,flag=; double a,b,c; while(scan ...

  2. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  3. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  4. MySQL所有函数及操作符

    参考:Function and Operator Reference Name Description ABS() Return the absolute value ACOS() Return th ...

  5. arcgis地图服务之 identify 服务

    arcgis地图服务之 identify 服务 在近期的一次开发过程中,利用IdentityTask工具查询图层的时候,请求的参数中ImageDisplay的参数出现了错误,导致查询直接不能执行,百度 ...

  6. 翻译:探索GLSL-用几何着色器(着色器库)实现法线可视化

    翻译:探索GLSL-用几何着色器(着色器库)实现法线可视化 翻译自: Exploring GLSL – Normal Visualizer with Geometry Shaders (Shader ...

  7. Extensions for Spatial Data

    http://dev.mysql.com/worklog/task/?spm=5176.100239.blogcont4270.8.j3asa7&id=6609 前文: 这两天因为项目原因看了 ...

  8. mysql 函数表

    Name Description ABS() Return the absolute value ACOS() Return the arc cosine ADDDATE() Add time val ...

  9. cvpr2015papers

    @http://www-cs-faculty.stanford.edu/people/karpathy/cvpr2015papers/ CVPR 2015 papers (in nicer forma ...

随机推荐

  1. WP8 学习 ApplicationBar 的创建 XAML代码

    phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar Opacity="0.1" IsVis ...

  2. java.net.SocketException: Too many open files

    1.ps -ef|grep java 2.lsof -p 32636 3.lsof -p 20812|wc –l   这个也可以看一个进程打开的文件数 4.ulimit –a c3p0官方提供了两个参 ...

  3. xlistview的(java)

    package com.bwie.xlistviews; import java.text.SimpleDateFormat;import java.util.Date; import com.bwi ...

  4. 类似github的框架

    github是程序员经常上的网站,但如果是在一家苦逼不能访问外网的公司,那不能把自己的代码托管在github上绝对是一件非常痛苦的事情.如果想要在公司内网也可以用github托管自己的代码,那就要自己 ...

  5. 无刷新 checkbox列表的删除

    前台 JS : function ModelDelete() { var checkvalues = null; var checValue = $("#dom1").find(& ...

  6. 关于Xcode调试的帖子,感觉不错,转来看看

    http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 http://www.raywenderlich.com/10505 ...

  7. 单例模式简单解析--Singleton 单例模式(懒汉方式和饿汉方式)

    单例模式的概念: 单例模式的意思就是只有一个实例.单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例.这个类称为单例类. 关键点: 1)一个类只有一个实例       这是最基本 ...

  8. LIST 和 MAP

    Collection和Map LIST 集合 arraylist arraylist源代码: 1.ArrayList 底层采用数组实现,当使用不带参数的构造方法生成 ArrayList 对象时,实际上 ...

  9. Shell获取当前用户

    id | sed -e 's/).*//g' -e 's/.*(//' 比$LOGNAME $NAME who am i都要准确一些

  10. 12-24 关于UIScroView 控件的学习

    在iOS开发中,滚动视图(UIScrollView)通常用于显示内容尺寸大于屏幕尺寸的视图.滚动视图有以下两个主要作用: 让用户可以通过拖拽手势来观看想看到的内容 让用户可以通过捏合手势来放大或缩小观 ...