日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HUST 1555 A Math Homework

發(fā)布時間:2025/4/14 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HUST 1555 A Math Homework 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1555 - A Math Homework

時間限制:1秒 內(nèi)存限制: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. } 題目鏈接:http://acm.hust.edu.cn/problem/show/1555 分析:題目大意就是求解三邊是否構(gòu)成三角形,如果是,它是鈍角三角形、銳角三角形還是直角三角形! 別看如此簡單,出題目的人挖空心思在坑人!提示告訴我們要用scanf輸入,不然估計又會超時吧! 剛開始想用數(shù)組輸,結(jié)果可想而知,直接WA,其實這題目也沒有那么復(fù)雜,就是先去判斷三邊是否構(gòu)成三角形,然后利用余弦定理(判斷任意兩邊的平方和減去第三邊的大小情況)大于0為銳角三角形,小于0為鈍角三角形,等于0為直角三角形! 也可以將這三條邊進行排序,然后取最短兩條邊的平方和與第三邊的平方進行比較求解! 下面給出AC代碼: 1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int a,b,c; 6 double s; 7 while(scanf("%d%d%d",&a,&b,&c)!=EOF) 8 { 9 if(a+b<=c||a+c<=b||b+c<=a) 10 printf("FAIL TO MAKE!\n"); 11 else 12 { 13 if(a*a+b*b-c*c==0||a*a+c*c-b*b==0||b*b+c*c-a*a==0) 14 printf("Right\n"); 15 else if(a*a+b*b-c*c<0||a*a+c*c-b*b<0||b*b+c*c-a*a<0) 16 printf("Obtuse\n"); 17 else printf("Acute\n"); 18 } 19 } 20 return 0; 21 }

?

轉(zhuǎn)載于:https://www.cnblogs.com/ECJTUACM-873284962/p/6394892.html

總結(jié)

以上是生活随笔為你收集整理的HUST 1555 A Math Homework的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。