結果

問題 No.3001 確率論ってこういうものですよね
ユーザー antaanta
提出日時 2015-10-26 23:46:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,083 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 78,388 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 04:12:43
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	//AA + AB = X
	//AA + BA = Y
	//0 <= AA, AB, BA
	//AA + AB + BA <= 1
	//linear programming
	//optimalな解は頂点にあるので、3つのlinearly independentな等式が成り立つはず
	//AA = 0:
	//	AA = 0, AB = X, BA = Y
	//	cond: X + Y <= 1
	//AB = 0:
	//	AA = X, AB = 0, BA = Y - X
	//	cond: Y - X >= 0
	//BA = 0:
	//	AA = Y, AB = X - Y, BA = 0
	//	cond: X - Y >= 0
	//AA + AB + BA = 1:
	//	AA = X + Y - 1, AB = 1 - Y, BA = 1 - X
	//	cond: 0 <= X + Y - 1 <= 1
	double X, Y;
	while(cin >> X >> Y) {
		vector<double> candidates;
		if(X + Y <= 1)
			candidates.push_back(X);
		if(Y - X >= 0)
			candidates.push_back(0);
		if(X - Y >= 0)
			candidates.push_back(X - Y);
		if(0 <= X + Y - 1 && X + Y - 1 <= 1)
			candidates.push_back(1 - Y);

		double mini = *min_element(all(candidates));
		double maxi = *max_element(all(candidates));
		printf("%.10f %.10f\n", maxi, mini);
	}
	return 0;
}
0