HUST 1555 A Math Homework
1555 - A Math Homework
时间限制:1秒 内存限制:128兆
- 题目描述
-
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的更多相关文章
- HUST 1555 数学作业
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html 1555 - A Math Homework 时间限制:1秒 内存限制:12 ...
- [HDU - 5170GTY's math problem 数的精度类
题目链接:HDU - 5170GTY's math problem 题目描述 Description GTY is a GodBull who will get an Au in NOI . To h ...
- 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 ...
- hdu 4983 Goffi and GCD(欧拉函数)
Problem Description Goffi is doing his math homework and he finds an equality on his text book: gcd( ...
- Calculation(dfs+状压dp)
Problem 1608 - Calculation Time Limit: 500MS Memory Limit: 65536KB Total Submit: 311 Accepted: ...
- sicily9162. RAZLIKA
9162. RAZLIKA 限制条件 时间限制: 2 秒, 内存限制: 256 兆 题目描述 Mirko's newest math homework assignment is a very dif ...
- Chapter 2 Open Book——14
I backpedaled. "They seemed nice enough to me. I just noticed they keptto themselves. 我改口说道,他们看 ...
- [SinGuLaRiTy] COCI 2011~2012 #2
[SinGuLaRiTy-1008] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 测试题目 对于所有的题目:Time Limit:1s ...
- codeforces463D
Gargari and Permutations CodeForces - 463D Gargari got bored to play with the bishops and now, after ...
随机推荐
- SourceTree for Mac 破解版
soureTree For mac 破解版下载地址:链接: https://pan.baidu.com/s/1c19kFRi 密码: ai7f
- Struts2学习---简单的数据校验、访问Web元素
1.简单的数据校验 在action里面我们已经给出了一个数据校验: public String execute() { if(user.getUsername().equals("usern ...
- iOS UIAlertController在Tableview中显示缓慢,迟钝,延迟
在UITableViewCell中弹窗Alert延迟.在cellForRow中:cell.selectionStyle = UITableViewCellSelectionStyleNone; 或者在 ...
- ElasticSearch 学习记录之ES查询添加排序字段和使用missing或existing字段查询
ES添加排序 在默认的情况下,ES 是根据文档的得分score来进行文档额排序的.但是自己可以根据自己的针对一些字段进行排序.就像下面的查询脚本一样.下面的这个查询是根据productid这个值进行排 ...
- MIG IP控制DDR3读写测试
本文设计思想采用明德扬至简设计法.在高速信号处理场合下,很短时间内就要缓存大量的数据,这时片内存储资源已经远远不够了.DDR SDRAM因其极高的性价比几乎是每一款中高档FPGA开发板的首选外部存储芯 ...
- JavaScript获取数组最小值和最大值的方法
本文实例讲述了JavaScript获取数组最小值和最大值的方法.分享给大家供大家参考.具体如下: ? 1 2 3 4 5 6 var arr = new Array(); arr[0] = 100; ...
- think queue 消息队列初体验
使用的是tp5 自带的消息队列 thinkphp top里的 消息队列框架 think-queue 这是thinkphp官方团队开发的一个专门支持队列服务的扩展包 消息队列应用场景: 消息队列适用于 ...
- 豹哥嵌入式讲堂:ARM开发之文件详解(3)- project文件
大家好,我是豹哥,猎豹的豹,犀利哥的哥.今天豹哥给大家讲的是嵌入式开发里的project文件. 前面两节课里,豹哥分别给大家介绍了嵌入式开发中的两种典型input文件:source文件.linker文 ...
- 用 HAproxy 搭建 RabbitMQ 集群
构建参考: [ Rabbitmq cluster setup with HAproxy ] [ python demo ] RabbitMQ Cluster 遇到的问题 python pika 作为c ...
- Go同步和异步执行多个任务封装
同步执行类RunnerAsync 支持返回超时检测,系统中断检测 错误常量定义 //超时错误 var ErrTimeout = errors.New("received timeout&qu ...