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. mac配置java和maven环境变量

    1.打开终端: 2.输入命令:sudo vi ~/.bash_profile进入编辑模式: 3.输入开机密码并按两次enter键进入编辑选择项: 4.输入i键进入文件插入模式输入配置信息: 5.按es ...

  2. 【java】扫描流Scanner接收输入示例

    多用Scanner少用InputStream 多用BufferedReader少用Reader 多用PrintStream少用OutputStream 多用PrintWriter少用Writer pa ...

  3. Principle-初步认识(简介)

    Principle官网 探究了一下 . 呃--作出了下边这玩意 做的好的是这样的,瞬间把自己给菜了,给大家看看,设计需要UI功夫啊 把这个用上你的界面就搞基了,图形在水平.垂直上的动态效果(*.*) ...

  4. Wincc flexable的画面浏览切换组态

    1.新建项目和6个画面 2.双击导航控件设置,选择默认设置 3.使用画面浏览编辑器编辑画面层次切换关系,拖拽画面到编辑器中进行关系连接 4.保运并运行

  5. php编码的一些小规范

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/104 最近在整理线上的hhvm warning,虽然每天产生百万 ...

  6. bzoj 3653 [湖南集训]谈笑风生

    题目描述 设 T 为一棵有根树,我们做如下的定义: • 设 a 和 b 为 T 中的两个不同节点.如果 a 是 b 的祖先,那么称"a 比 b 不知道高明到哪里去了". • 设 a ...

  7. locate 命令详解

    locate :http://www.cnblogs.com/peida/archive/2012/11/12/2765750.html 作用:locate命令可以在搜寻数据库时快速找到档案,数据库由 ...

  8. 微信小程序如何开发制作

    微信小程序如何开发制作 微容SMO是一款微信小程序的免费在线制作工具,用户在微容平台上无需编辑代码,可通过拖拽式操作即可完成小程序的制作,真正意义上实现了小程序零代码免费制作! 消除技术门槛:无需代码 ...

  9. CSS实现商城分类导航效果(hover选择器)

    学完制作出这个导航效果之后,收获最多的是了解了hover选择器的功能,:hover 选择器用于选择鼠标指针浮动在上面的元素.在鼠标移到元素上时向此元素添加特殊的样式(CSS).例如:改变鼠标悬停处的元 ...

  10. 佛祖保佑永无bug的源代码

    ${AnsiColor.BRIGHT_YELLOW} ${AnsiColor.BRIGHT_RED}_ooOoo_${AnsiColor.BRIGHT_YELLOW} ${AnsiColor.BRIG ...