結果

問題 No.306 さいたま2008
ユーザー startcppstartcpp
提出日時 2015-11-27 22:55:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 74,096 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 00:17:35
合計ジャッジ時間 1,781 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,352 KB
testcase_01 AC 8 ms
4,348 KB
testcase_02 AC 6 ms
4,348 KB
testcase_03 AC 12 ms
4,352 KB
testcase_04 AC 12 ms
4,348 KB
testcase_05 AC 9 ms
4,348 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 26 ms
4,348 KB
testcase_11 AC 24 ms
4,352 KB
testcase_12 AC 25 ms
4,352 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 6 ms
4,348 KB
testcase_18 AC 5 ms
4,352 KB
testcase_19 AC 27 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 7 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:14: warning: ‘pos’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  for( double y = pos - 0.01; y <= pos + 0.01; y += 1e-7 ){
              ^

ソースコード

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>
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-3 ){
		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-7 ){
		double d = hypot(x1, y1 - y) + hypot(x2, y2 - y);
		if( d < mind ){
			mind = d;
			pos = y;
		}
	}
	printf("%.12f\n", pos);
	return 0;
}
0