結果

問題 No.1175 Simultaneous Equations
ユーザー Mister
提出日時 2020-08-21 23:44:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 77,096 KB
最終ジャッジ日時 2025-01-13 06:37:03
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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