結果

問題 No.306 さいたま2008
ユーザー zaichuzaichu
提出日時 2015-12-30 23:38:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 160,804 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 12:46:15
合計ジャッジ時間 3,751 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	double Xa,Ya,Xb,Yb;
	cin >> Xa >> Ya >> Xb >> Yb;
	double mins = INT_MAX;
	double ans;
	for(double i = min(Ya,Yb); i <= max(Yb,Ya); i+=0.00001){
		double d1;
		double d2;
		if(min(Ya,Yb) == Ya){
			d1 = sqrt(Xa * Xa + (i - Ya) * (i - Ya));
			d2 = sqrt(Xb * Xb + (Yb - i) * (Yb - i));
		}else{
			d1 = sqrt(Xb * Xb + (i - Yb) * (i - Yb));
			d2 = sqrt(Xa * Xa + (Ya - i) * (Ya - i));
		}		
		//		cout << i << " " << d1+d2 << endl;
		if(mins > (d1+d2)){
			mins = (d1+d2);
			ans = i;
		}
		else break;
	}
	cout << ans << endl;		
	return 0;
}
0