結果
| 問題 |
No.306 さいたま2008
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2015-11-27 22:58:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 762 ms / 2,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 83,948 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-14 12:09:46 |
| 合計ジャッジ時間 | 10,861 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:46: warning: ‘pos’ may be used uninitialized [-Wmaybe-uninitialized]
33 | for( double y = pos - 0.01; y <= pos + 0.01; y += 1e-8 ){
| ~~~~^~~~~~
main.cpp:24:16: note: ‘pos’ was declared here
24 | double pos, mind = 114514;
| ^~~
ソースコード
#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;
}
startcpp