結果

問題 No.306 さいたま2008
ユーザー startcppstartcpp
提出日時 2015-11-27 22:58:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,271 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 74,068 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 00:22:01
合計ジャッジ時間 13,771 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
4,352 KB
testcase_01 AC 322 ms
4,348 KB
testcase_02 AC 200 ms
4,476 KB
testcase_03 AC 510 ms
4,352 KB
testcase_04 AC 508 ms
4,352 KB
testcase_05 AC 339 ms
4,352 KB
testcase_06 AC 236 ms
4,348 KB
testcase_07 AC 612 ms
4,348 KB
testcase_08 AC 208 ms
4,348 KB
testcase_09 AC 246 ms
4,348 KB
testcase_10 AC 1,195 ms
4,352 KB
testcase_11 AC 1,131 ms
4,352 KB
testcase_12 AC 1,116 ms
4,352 KB
testcase_13 AC 199 ms
4,348 KB
testcase_14 AC 199 ms
4,348 KB
testcase_15 AC 209 ms
4,352 KB
testcase_16 AC 252 ms
4,352 KB
testcase_17 AC 201 ms
4,352 KB
testcase_18 AC 200 ms
4,352 KB
testcase_19 AC 1,271 ms
4,352 KB
testcase_20 AC 1,197 ms
4,352 KB
testcase_21 AC 1,200 ms
4,348 KB
testcase_22 AC 241 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:14: warning: ‘pos’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  for( double y = pos - 0.01; y <= pos + 0.01; y += 1e-8 ){
              ^

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define double long double
using namespace std;

int main()
{
	double x1, y1;
	double x2, y2;
	cin >> x1 >> y1;
	cin >> x2 >> y2;
	
	double pos, mind = 114514;
	for( double y = min(y1, y2); y <= max(y1, y2); y += 1e-4 ){
		double d = hypot(x1, y1 - y) + hypot(x2, y2 - y);
		if( d < mind ){
			mind = d;
			pos = y;
		}
	}
	
	for( double y = pos - 0.01; y <= pos + 0.01; y += 1e-8 ){
		double d = hypot(x1, y1 - y) + hypot(x2, y2 - y);
		if( d < mind ){
			mind = d;
			pos = y;
		}
	}
	printf("%.14Lf\n", pos);
	return 0;
}
0