結果
問題 | No.419 直角三角形 |
ユーザー |
|
提出日時 | 2017-02-20 20:18:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 539 bytes |
コンパイル時間 | 980 ms |
コンパイル使用メモリ | 65,200 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 10:50:51 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <iostream>#include <math.h>#include <iomanip>using namespace std;int main(){int a,b;cin >> a >> b;double ans = 0;/*a^2 + b^2 = c^2 -> sqrt(a^2+b^2)a^2 + c^2 = b^2 -> sqrt(b^2-a^2)b^2 + c^2 = a^2 -> sqrt(a^2-b^2)*///ans = sqrt(a*a+b*b);if(b*b-a*a > 0){//b^2-a^2=0の時は?→考慮しないと0が出力ans = (double)sqrt(b*b-a*a);}else if(a*a-b*b > 0){ans = (double)sqrt(a*a-b*b);}else{ans = (double)sqrt(a*a+b*b);}cout << fixed << setprecision(7) << ans << endl;return 0;}