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. SpringBoot学习笔记

    SpringBoot个人感觉比SpringMVC还要好用的一个框架,很多注解配置可以非常灵活的在代码中运用起来: springBoot学习笔记: .一.aop: 新建一个类HttpAspect,类上添 ...

  2. sqlserver 存储过程 递归查询分组+hierarchyid重建会员关系

    CREATE PROCEDURE [dbo].[GetGroupInfo] @s_code NVARCHAR() = --会员卡号 AS BEGIN declare @p int; --查询唯一性结果 ...

  3. IX-Protected Dataplane Operating System解读

    一.概述 商业操作系统在应用程序每秒钟需要数百万次操作时才能保持高吞吐量和低(尾)延迟,对于最慢的请求只需几百微秒.通常认为对于高性能网络(小信息的高包率.低延迟)的构建,最好都是在内核之外构建用户态 ...

  4. IOS学习5——属性与成员变量

    [转]iOS中属性与成员变量的区别 ios中属性修饰符的作用 1. 属性用property声明 2. 简而言之,对于目前的ios开发,属性和成员变量的区别,完全可以不管. 3. 这个是历史原因造成的. ...

  5. Python学习日记:day2

    1.格式化输出 name = input("请输入你的名字:") age =input("请输入你的年龄:") job =input("请输入你的工作 ...

  6. CSS3关于过渡效果的问题

    首先trasition:transform只是单单表示后面只要有含有的tranform的所有属性可以参与动画,而trasition:all表示后面所有动画属性都可以参动画,当父容器有relative时 ...

  7. 深度搜索DFS-Lake Counting(POJ NO.2386)

    题目链接POJ NO.2386 解题思路: 这个也是一个dfs 的应用,在书上的例子,因为书上的代码并不全,基本都是函数分块来写,通过这个题目也规范了代码,以后能用函数的就都用函数来实现吧.采用深度优 ...

  8. 关于文件上传的ajax交互

    首先我们来了解一下上传文件 <input type="file"> input的file常用上传类型 后缀名 MIME名称 *.3gpp audio/3gpp, vid ...

  9. BLE抓包是怎么回事儿?

    BLE抓包 在进行网络开发的时候,抓包是一个很重要的调试过程,通过抓包可以分析网络传输的数据是否正确,可以深入理解网络传输过程.在物联网开发中,BLE低功耗蓝牙技术是一种非常通用的网络传输方式.在学习 ...

  10. Webpack 2 视频教程 020 - Webpack 2 中的 HMR ( Hot Module Replacement )

    原文发表于我的技术博客 这是我免费发布的高质量超清「Webpack 2 视频教程」. Webpack 作为目前前端开发必备的框架,Webpack 发布了 2.0 版本,此视频就是基于 2.0 的版本讲 ...