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.
}
题目链接:http://acm.hust.edu.cn/problem/show/1555
分析:题目大意就是求解三边是否构成三角形,如果是,它是钝角三角形、锐角三角形还是直角三角形!
别看如此简单,出题目的人挖空心思在坑人!提示告诉我们要用scanf输入,不然估计又会超时吧!
刚开始想用数组输,结果可想而知,直接WA,其实这题目也没有那么复杂,就是先去判断三边是否构成三角形,然后利用余弦定理(判断任意两边的平方和减去第三边的大小情况)大于0为锐角三角形,小于0为钝角三角形,等于0为直角三角形!
也可以将这三条边进行排序,然后取最短两条边的平方和与第三边的平方进行比较求解!
下面给出AC代码:
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int a,b,c;
 6     double s;
 7     while(scanf("%d%d%d",&a,&b,&c)!=EOF)
 8     {
 9         if(a+b<=c||a+c<=b||b+c<=a)
10          printf("FAIL TO MAKE!\n");
11         else
12         {
13             if(a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0)
14                printf("Right\n");
15                else if(a*a+b*b-c*c<0||a*a+c*c-b*b<0||b*b+c*c-a*a<0)
16                 printf("Obtuse\n");
17                else printf("Acute\n");
18         }
19     }
20     return 0;
21 }

转载于:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html

HUST 1555 A Math Homework相关推荐

  1. good helper for your math homework: https://www.wolframalpha.com/

    https://www.wolframalpha.com/

  2. Codeforces #264 (Div. 2) D. Gargari and Permutations

    Gargari got bored to play with the bishops and now, after solving the problem about them, he is tryi ...

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

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

  4. Gargari and Permutations CodeForces - 463D(建图+记忆化搜索)

    Gargari got bored to play with the bishops and now, after solving the problem about them, he is tryi ...

  5. usb 驱动修复_您可以修复物理损坏的USB驱动器吗?

    usb 驱动修复 Sometimes accidents happen to a USB drive, and you find yourself in a very bad position whe ...

  6. alert 回调_JavaScript中到底什么时候回调函数Callback

    什么是回调函数Callback 简单的理解:回调函数是在另一个函数执行完毕后执行的函数 - 因此名称为'call back'. 复杂的理解:在JavaScript中,函数是对象.因此,函数可以将函数作 ...

  7. 怎么赚美金_我16岁时如何赚到200,000美元

    怎么赚美金 by RJ 由RJ About three years ago, I published a story about how the Twitter app I built in high ...

  8. [译] JavaScript:回调是什么鬼?

    本文讲的是[译] JavaScript:回调是什么鬼?, 原文地址:JavaScript: What the heck is a Callback? 原文作者:Brandon Morelli 译文出自 ...

  9. 二十一世纪大学英语读写教程学习笔记(原文)——6 - Nerds and Geeks(书呆子和极客)

    Unit 6 - Nerds and Geeks(书呆子和极客) Nerds and Geeks Leonid Fridman There is something very wrong with t ...

最新文章

  1. 输出超限怎么解决 oj_三菱PLC输出指示灯输出模块不亮怎么解决
  2. python好用-6个炫酷又好用的 Python 工具,个个都很奔放呀
  3. mybatis-嵌套(关联)查询/ N+1 / 延迟加载
  4. 学习Promise之前你必须理解的知识点:异步处理的通用模型
  5. ubuntu里面的任务管理器
  6. data/mysql_error_trace.inc,09-在线挑战详细攻略-《真的很简单》
  7. python重试库retryiny源码剖析
  8. FreeRTOS 教程指南 学习笔记 第三章 任务管理(二)
  9. 拍的视频怎么把录音去掉?
  10. 【武忠祥高等数学基础课笔记】第一章 函数、极限、连续
  11. 自动驾驶对公路基础设施有何深刻影响?(上)| 自动驾驶系列
  12. 工行u盾控件没有在您的机器上检测到u盾,请您检查u盾是否插入计算机,工行u盾电脑检测不到:控件没有在您的机器上检测到u盾...
  13. 分位数回归(Quantile Regression)
  14. kali:hydra破解ssh密码
  15. 如何生成密钥文件Snk .
  16. php 百度网盘上传文件大小限制吗,百度云存储,curl_百度云存储如何上传数G超大文件(视频类)和防盗链等一系列问题,百度云存储,curl - phpStudy...
  17. 7月14日第壹简报,星期四,农历六月十六
  18. Android指纹解锁
  19. 2008年超级计算机排名,2008年Opteron超级计算机性能将突破1petaflop
  20. 12 Roll A Ball全部代码

热门文章

  1. 使用Firebug或chrome-devToolBar深入学习javascript语言核心
  2. sonar 代码质量管理平台
  3. 请大家访问另一个我的博客!
  4. ASP.NET生命周期详解(转)
  5. 提高团队整体能力-同一片天“技术交流会”
  6. 关于mysql服务器3306端口不能远程连接的解决
  7. eclipse+ADT下android开发AVD若干问题
  8. 关于图像语义分割的总结和感悟
  9. 二分图最大匹配的König定理及其证明
  10. JDK源码解析 Runable是一个典型命令模式,Runnable担当命令的角色,Thread充当的是调用者,start方法就是其执行方法