結果

問題 No.1175 Simultaneous Equations
ユーザー MisterMister
提出日時 2020-08-21 23:44:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 81,360 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 06:34:22
合計ジャッジ時間 1,068 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>

using ldouble = long double;

void solve() {
    std::vector<ldouble> xs(3), ys(3);
    for (auto& x : xs) std::cin >> x;
    for (auto& y : ys) std::cin >> y;

    ldouble p = ys[0] / xs[0];
    for (int i = 0; i < 3; ++i) ys[i] -= xs[i] * p;

    ldouble b = ys[2] / ys[1];
    ldouble a = (xs[2] - xs[1] * b) / xs[0];

    std::cout << a << " " << b << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);

    solve();

    return 0;
}
0