結果

問題 No.306 さいたま2008
ユーザー chuka231chuka231
提出日時 2015-11-27 23:48:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 58,452 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 01:37:24
合計ジャッジ時間 56,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	}
	else {
		double tmp = 1000000.0;
		double p = min(ay, by);
		
		for (double d = 0; d < 1000; d += 0.000001) {
			double dis = sqrt(ax*ax + (ay - d)*(ay - d)) + sqrt(bx*bx + (by - d)*(by - d));
			if (dis < tmp) {
				p = d;
				tmp = dis;
			}
		}

		cout << (ay + by) / 2 << endl;
	}

	return 0;
}
0