結果

問題 No.419 直角三角形
ユーザー kichirb3
提出日時 2018-03-19 00:27:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 643 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 73,044 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 12:36:30
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.419 直角三角形
// https://yukicoder.me/problems/no/419
//
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double solve(double a, double b);


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    double a, b;
    cin >> a >> b;
    double ans = solve(a, b);
    cout << fixed << setprecision(8) << ans << endl;
}

double solve(double a, double b) {
    double ans;
    if (a == b)
        ans = sqrt(a*a + b*b);
    else {
        if (b > a) {
            double t = a;
            a = b;
            b = t;
        }
        ans = sqrt(a*a - b*b);
    }
    return ans;
}
0