记录编号 571010 评测结果 AAAAAA
题目名称 饲料调配 最终得分 100
用户昵称 Gravatarlihaoze 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2022-05-02 15:54:50 内存使用 0.00 MiB
显示代码纯文本
#include <bits/stdc++.h>
#define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
#define rep(_x, _y, _z) for (int _x = (_y); _x <= (_z); ++ _x)
#define rep1(_x, _y, _z) for (int _x = (_y); _x < (_z); ++ _x)
#define fi first
#define se second

using i64 = long long;
using PII = std::pair<int, int>;

const double eps = 1e-8;
double sav[4][5], a[4][5];

bool gauss() {
    double now;
    rep1 (i, 0, 3) {
        int t = i;
        rep1 (j, i + 1, 3) if (fabs(a[j][i]) > fabs(a[t][i])) t = j;
        if (fabs(now = a[t][i]) < eps) return true;
        rep (j, i, 3) std::swap(a[i][j], a[t][j]);
        rep (j, i, 3) a[i][j] /= now;
        rep1 (j, 0, 3) if (j != i) {
            now = a[j][i];
            rep (k, i, 3) a[j][k] -= a[i][k] * now;
        }
    }
    return false;
}

int main() {
    OPEN(ratios);
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    rep1 (i, 0, 3) std::cin >> sav[i][3];
    rep1 (i, 0, 3) rep1 (j, 0, 3) std::cin >> sav[j][i];
    rep (res, 1, 100) {
        memcpy(a, sav, sizeof a);
        rep1 (i, 0, 3) a[i][3] *= res;
        if (!gauss()) {
            bool flag = false;
            rep1 (j, 0, 3) {
                if (a[j][3] - int(a[j][3]) > eps && int(a[j][3] + eps) == int(a[j][3]) || a[j][3] + eps < 0) {
                    flag = 1;
                    break;
                }
            }
            if (!flag) {
                rep1 (j, 0, 3) std::cout << int(a[j][3] + eps) << ' ';
                std::cout << res << '\n';
                return 0;
            }
        }
    }
    std::cout << "NONE" << '\n';
    return 0;
}