結果

問題 No.1175 Simultaneous Equations
ユーザー Kunta (coder)Kunta (coder)
提出日時 2020-08-21 22:06:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 164,412 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-05 08:06:45
合計ジャッジ時間 2,451 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MoD 1e9 + 7
#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for(int i = a; i < b; i++)
//#define re(i, a, b) for(int i = b; i > a; i--)
#define pb(a) push_back(a)

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int a, b, c, d, e, f;

int gcm(int a1, int b1){
	int n_mx=max(a1,b1);
	int n_mi=min(a1,b1);
	int m= n_mx % n_mi;
	if(m!=0) return gcm(m, n_mi);
	else return n_mi;
}
int lcm(int a1,int b1){
	return (a1*b1/gcm(a1,b1));
}

void solve(){
	cin >> a >> b >> c >> d >> e >> f;

	double xf= lcm(a,d), yf= lcm(b,e);
	cout.precision(20);
	cout << ((yf*c/b)-(yf*f/e))/((yf*1.0*a/b)-(yf*1.0*d/e)) << ' ' << ((xf*c/a)-(xf*f/d))/((xf*1.0*b/a)-(xf*1.0*e/d)) << '\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t=1;
	for(int i=1; i<=t; ++i) {
		solve();
	}

}
0