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 ...
随机推荐
- IP地址简介
IP地址 IP地址,Internet Protocol Address,网络协议地址: IP地址与网络接口绑定,并不是指向一台主机,一个主机可能有多个IP地址,如果其连接多个网络,有多个网络接口: I ...
- oracle初级(续)
有志者.事竟成,破釜沉舟,百二秦关终属楚: 苦心人.天不负,卧薪尝胆,三千越甲可吞吴. oracle基本简单的用法,之前的笔记稍作整理一下,希望对各位有用,如有问题可在下方留言,所有SQL都是经过or ...
- Dubbo(三) 安装Zookeeper 单机-集群
一.下载zookeeper zookeeper下载地址:https://www.apache.org/dyn/closer.cgi/zookeeper/点击下载 二.启动配置 选择合适版本下载后解压到 ...
- SQL基础学习_02_查询
SELECT语句 1. SELECT语句查询列(字段): SELECT <列名> FROM <表名>; 该语句使用了两个SQL子句,SELECT子句列举了 ...
- vuex 基本用法、兄弟组件通信,参数传递
vuex主要是是做数据交互,父子组件传值可以很容易办到,但是兄弟组件间传值,需要先将值传给父组件,再传给子组件,异常麻烦. vuex大概思路:a=new Vue(),发射数据'msg':a.$emit ...
- XCopy命令实现增量备份
xcopy XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行C ...
- MySQL优化五 SQL优化
1.减少 IO 次数 IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当然 ...
- 使用git工具将项目上传到github
注册github账号 https://github.com/ 安装git工具: https://git-for-windows.github.io/ 上面的准备工作完成后,现在开始操作. 一.进入gi ...
- Pycharm使用总结
1.代码整体向右移动 按住Win+TAB可以快速向右缩进一个tab 的距离,按住Shift + TAB反方向前进一个TAB距离 2.Model加入get,set 方法 在编辑框中右击,选择genera ...
- Vue自己写组件——Demo详细步骤
公司近期发力,同时开了四五个大项目,并且都是用Vue来做的,我很荣幸的被分到了写项目公用模块的组,所以需要将公用的部分提取成组件的形式,供几个项目共同使用,下面详细讲一下写Vue组件的具体步骤. 一. ...