結果

問題 No.306 さいたま2008
ユーザー chuka231
提出日時 2015-11-27 23:48:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 59,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 01:27:33
合計ジャッジ時間 49,093 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 TLE * 19
権限があれば一括ダウンロードができます

ソースコード

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