結果
| 問題 |
No.306 さいたま2008
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-30 01:19:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,275 bytes |
| コンパイル時間 | 563 ms |
| コンパイル使用メモリ | 60,120 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 18:56:32 |
| 合計ジャッジ時間 | 1,294 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
ソースコード
#include <iostream>
#include <math.h>
const long double INC_MIN = 0.0000000000001;
long double pyt(long double sa, long double sb)
{
return ::sqrt((sa * sa) + (sb * sb));
}
long double f(long double ax, long double ay, long double bx, long double by)
{
long double p_min = ay < by? ay: by;
long double p_len = ::fabs(ay - by);
long double p_max = p_min + p_len;
long double rc = ax - p_max;
long double wk = pyt(ax, p_len) + bx;
long double inc = 1;
long double n = 0;
long double begin = 0;
long double end = p_len;
while (inc > INC_MIN) {
n = begin;
while (n <= end) {
long double a = pyt(ax, (ay < by? n: (p_len - n)));
long double b = pyt(bx, (by < ay? n: (p_len - n)));
long double w = a + b;
if (w < wk) {
wk = w;
rc = n;
}
n += inc;
}
if (rc >= inc) begin = rc - inc;
end = rc + inc;
inc /= 10;
}
return p_min + rc;
}
int main()
{
long double ax, ay, bx, by;
std::cin >> ax;
std::cin >> ay;
std::cin >> bx;
std::cin >> by;
if (ay == by) std::cout << ay << std::endl;
else std::cout << f(ax, ay, bx, by) << std::endl;
return 0;
}