1555 - A Math Homework

时间限制:1秒 内存限制:128兆

338 次提交 131 次通过
题目描述
    QKL is a poor and busy guy, and he was not good at math. 
    Last day, his teacher assigned a homework: Give you 3 segments with positive length, can you use these segments to make a triangle? If can, what is the type of the triangle? Acute triangle, right triangle or obtuse triangle? Pay attention that vertices of triangle must be vertices of two segments.
    QKL is afraid of any type of math problems, so he turns to you for help. Can you help him?
输入
Several test cases, one line per case.
In case consists of three positive integers: a, b, c, indicating the lengths of 3 segments.
0 < a, b, c <= 10000
输出
In each test case, you just print one line of result.
If you can't make a triangle by using these segments, print "FAIL TO MAKE!"(quote for clarify).
If you can make an acute triangle, print "Acute"(quote for clarify).
If you can make a right triangle, print "Right"(quote for clarify).
If you can make an obtuse triangle, print "Obtuse"(quote for clarify).
样例输入
1 2 3
2 3 4
3 4 5
4 5 6
样例输出
FAIL TO MAKE!
Obtuse
Right
Acute
提示
You can use this form of code to deal with several test cases.
 
while (scanf("%d%d%d", &a, &b, &c) != EOF)
{
//Your codes here.
}
分析:题目大意就是求解三边是否构成三角形,如果是,它是钝角三角形、锐角三角形还是直角三角形!
别看如此简单,出题目的人挖空心思在坑人!提示告诉我们要用scanf输入,不然估计又会超时吧!
刚开始想用数组输,结果可想而知,直接WA,其实这题目也没有那么复杂,就是先去判断三边是否构成三角形,然后利用余弦定理(判断任意两边的平方和减去第三边的大小情况)大于0为锐角三角形,小于0为钝角三角形,等于0为直角三角形!
也可以将这三条边进行排序,然后取最短两条边的平方和与第三边的平方进行比较求解!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
double s;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(a+b<=c||a+c<=b||b+c<=a)
printf("FAIL TO MAKE!\n");
else
{
if(a*a+b*b-c*c==||a*a+c*c-b*b==||b*b+c*c-a*a==)
printf("Right\n");
else if(a*a+b*b-c*c<||a*a+c*c-b*b<||b*b+c*c-a*a<)
printf("Obtuse\n");
else printf("Acute\n");
}
}
return ;
}

HUST 1555 A Math Homework的更多相关文章

  1. HUST 1555 数学作业

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html 1555 - A Math Homework 时间限制:1秒 内存限制:12 ...

  2. [HDU - 5170GTY's math problem 数的精度类

    题目链接:HDU - 5170GTY's math problem 题目描述 Description GTY is a GodBull who will get an Au in NOI . To h ...

  3. BestCoder Round #29——A--GTY's math problem(快速幂(对数法))、B--GTY's birthday gift(矩阵快速幂)

    GTY's math problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  4. hdu 4983 Goffi and GCD(欧拉函数)

    Problem Description Goffi is doing his math homework and he finds an equality on his text book: gcd( ...

  5. Calculation(dfs+状压dp)

    Problem 1608 - Calculation Time Limit: 500MS   Memory Limit: 65536KB    Total Submit: 311  Accepted: ...

  6. sicily9162. RAZLIKA

    9162. RAZLIKA 限制条件 时间限制: 2 秒, 内存限制: 256 兆 题目描述 Mirko's newest math homework assignment is a very dif ...

  7. Chapter 2 Open Book——14

    I backpedaled. "They seemed nice enough to me. I just noticed they keptto themselves. 我改口说道,他们看 ...

  8. [SinGuLaRiTy] COCI 2011~2012 #2

    [SinGuLaRiTy-1008] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 测试题目 对于所有的题目:Time Limit:1s   ...

  9. codeforces463D

    Gargari and Permutations CodeForces - 463D Gargari got bored to play with the bishops and now, after ...

随机推荐

  1. Microsoft Visual Studio 2012旗舰版(VS2012中文版下载)官方中文版

    Microsoft Visual Studio 2012 Ultimate旗舰版(VS2012中文版下载)是一个最先进的开发解决方案,它使各种规模的团队能够设计和创建出使用户欣喜的引人注目的应用程序. ...

  2. Java JTS & 空间数据模型

    空间数据模型 判断两个几何图形是否存在指定的空间关系.包括: 相等(equals).分离(disjoint).相交(intersect).相接(touches).交叉(crosses).包含于(wit ...

  3. Java 管程解决生产者消费者问题

    同样是实验存档.//.. 依然以生产者消费者问题作为背景. 管程(=“资源管理程序”)将资源和对资源的操作封装起来,资源使用者通过接口操作资源就 ok,不用去考虑进程同步的问题. 管程: packag ...

  4. Python数据分析工具

    1.Numpy 安装:pip install numpy [root@kvm work]# cat numpy_test.py #!/usr/bin/env python #coding:utf-8 ...

  5. js基础:对DOM进行操作,删除、添加元素

    <body> <div id="div1"> <p id="p1">第一段</p> <p id=" ...

  6. JDK动态代理[4]----ProxyGenerator生成代理类的字节码文件解析

    通过前面几篇的分析,我们知道代理类是通过Proxy类的ProxyClassFactory工厂生成的,这个工厂类会去调用ProxyGenerator类的generateProxyClass()方法来生成 ...

  7. copy&deepcopy

    import copy 字典参照列表结论,看是否有深层嵌套. a = {'name':1,'age':2} b = a a['name'] = 'ff' print(a) print(b) print ...

  8. Spring之设置Bean值

    Java实例的属性值可以有很多种数据类型.基本类型值.字符串类型.java实例甚至其他的Bean实例.java集合.数组等.所以Spring允许通过如下几个元素为Bean实例的属性指定值: value ...

  9. 每天学一点Docker(1)

    Docker能做些什么? 1.docker能够解决虚拟机能够解决的问题 2.隔离应用依赖 3.创建应用镜像并复制 4.创建容易分发的即启即用的应用 5.docker的想法是创建软件程序可移植的轻量容器 ...

  10. 关于php变量的赋值和引用的区别

    刚开始学习php,发现有些地方和js语法不同,所以记录下来. 这篇文章是总结php中变量赋值和引用的区别. 我们知道,js中,原始类型的赋值,是将值直接复制给变量:引用类型的赋值,是将内存地址复制给变 ...