結果

問題 No.328 きれいな連立方程式
ユーザー ayame_pyayame_py
提出日時 2016-01-03 21:25:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,119 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 166,628 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 14:49:27
合計ジャッジ時間 2,816 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,n,m) for (int i=n; i<(int)(m); i++)
#define INF 1000000007

typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS = 1E-8;

int c1,c2,c3,c4;

vec gauss_jordan(const mat& A, const vec& b){
    int n=A.size();
    mat B(n, vec(n+1));
    REP(i,n) REP(j,n) B[i][j]=A[i][j];
    REP(i,n) B[i][n]=b[i];
    REP(i,n){
        int pivot=i;
        FOR(j,i,n){
            if(abs(B[j][i]) > abs(B[pivot][i])) pivot=j;
        }
        swap(B[i],B[pivot]);
        if (abs(B[i][i])<EPS) return vec();
        FOR(j,i+1,n+1) B[i][j]/=B[i][i];
        REP(j,n) if(i!=j) FOR(k,i+1,n+1) B[j][k] -= B[j][i] * B[i][k];
    }
    vec x(n);
    REP(i,n) x[i]=B[i][n];
    return x;
}


int main(){
    cin >> c1 >> c2 >> c3 >> c4;
    mat A(2, vec(2));
    A[0][0]=c2;A[0][1]=-c1;
    A[1][0]=c3;A[1][1]=-c2;
    vec b(2);b[0]=c3;b[1]=c4;
    vec ans=gauss_jordan(A, b);
    double za=ans[0];
    double zb=ans[1];
    if(za*za-4*zb<0) cout << 'I' << endl;
    else cout << 'R' << endl;
    
    return 0;
}
0