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 ...
随机推荐
- 什么是副作用(Side Effect)
副作用(Side Effect)是指函数或者表达式的行为依赖于外部世界.具体可参照Wiki上的定义,副作用是指 1)函数或者表达式修改了它的SCOPE之外的状态 2)函数或者表达式除了返回语句外还与外 ...
- C 函数参数 char **s与char *s[]
本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/126 先来看一个小例子 : 编写函数遍历一个整型数组的元素,数组 ...
- bzoj 3192: [JLOI2013]删除物品
Description 箱子再分配问题需要解决如下问题: (1)一共有N个物品,堆成M堆. (2)所有物品都是一样的,但是它们有不同的优先级. (3)你只能够移动某堆中位于顶端的物品. ( ...
- pycharm2017.3专业版激活注册码
pycharm作为一个不错的python编程的ide很有用处 这里拔出一段专业版的注册码,社区版用起来确实着实让人着急. 2017-12-1921:40:38 EB101IWSWD-eyJsaWNlb ...
- JavaScript Array 对象方法 以及 如何区分javascript中的toString()、toLocaleString()、valueOf()方法
1.concat() 2.join() 3.pop() 4.push() 5.reverse() 6.shift() 7.unshift() 8.slice() 9.sort() 10.splice( ...
- libcurl的使用
http://blog.csdn.net/ixiaochouyu/article/details/47998267
- 小谈SQL表的连接
简述SQL连接 SQL连接呢,主要分为以下几种内连接,左连接,右连接,全连接(当然还有很多官方的说法,这里就讲讲最常用的). 既然都叫连接了,那至少要有两个对象,也就是说,至少要有两个表,要怎么样的表 ...
- zabbix 3.0.4 中文字体替换
zabbix 对中文支持不是很好,会出现乱码: 从windows系统里 找到字体包:如图: 拷贝到zabbix-server里面,注意,把文件名改成小写: 我linux 是centos7.2版本 [r ...
- Robot Framework学习笔记(四)------Screenshot 库屏幕截图
Scrennshot 同样为 Robot Framework 标准类库,我们只将它提供的其它中一个关键字"TakeScreenshot",它用于截取到当前窗口. 1.导入Scren ...
- MAC上安装mysql及workbench
下载mysql for mac https://dev.mysql.com/downloads/installer/ 官网下载很慢---百度云:链接: https://pan.baidu.com ...