結果

問題 No.306 さいたま2008
ユーザー chuka231chuka231
提出日時 2015-11-27 23:59:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 59,116 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 01:53:17
合計ジャッジ時間 5,630 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 271 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 122 ms
4,352 KB
testcase_06 AC 32 ms
4,352 KB
testcase_07 AC 308 ms
4,352 KB
testcase_08 AC 9 ms
4,352 KB
testcase_09 AC 41 ms
4,348 KB
testcase_10 AC 805 ms
4,352 KB
testcase_11 AC 759 ms
4,352 KB
testcase_12 AC 750 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 1 ms
4,356 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

double min(double a, double b)
{
	if (a > b) return b;
	else return a;
}
double max(double a, double b)
{
	if (a < b) return b;
	else return a;
}

int main()
{
	double ax, ay, bx, by;
	cin >> ax >> ay;
	cin >> bx >> by;

	if (ay == by) {
		cout << ay << endl;
		return 0;
	}
	else if (ax == bx) {
		cout << (ay + by) / 2 << endl;
		return 0;
	}
	else {
		double tmp = 1000000.0;
		double p = min(ay, by);
		
		for (double d = min(ay,by); d <= max(ay,by); d = d + 0.00001) {
			double dis = sqrt(ax*ax + (ay - d)*(ay - d)) + sqrt(bx*bx + (by - d)*(by - d));
			if (dis < tmp) {
				p = d;
				tmp = dis;
			}
		}

		cout << p - 0.000005 << endl;
	}

	return 0;
}
0