結果
問題 |
No.306 さいたま2008
|
ユーザー |
![]() |
提出日時 | 2017-07-06 02:34:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,768 bytes |
コンパイル時間 | 1,574 ms |
コンパイル使用メモリ | 162,692 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-14 12:14:16 |
合計ジャッジ時間 | 2,414 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘void _main()’: main.cpp:47:19: warning: use of ‘ll’ length modifier with ‘f’ type character has either no effect or undefined behavior [-Wformat=] 47 | printf("%.10llf\n", p); | ^
ソースコード
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- typedef long double ld; const double EPS = 1e-9; template<typename Func> ld findMinReal(ld L, ld R, Func f) { //[L, R) ld left = L, right = R; for (int loop = 0; loop < 101010; ++loop) { if (f((left * 2 + right) / 3) <= f((left + right * 2) / 3)) { right = (left + right * 2) / 3; } else { left = (left * 2 + right) / 3; } } return (right + left) * 0.5; } /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ ld a, b, c, d; //--------------------------------------------------------------------------------------------------- ld f(ld x) { ld d1 = sqrt(a * a + (b - x) * (b - x)); ld d2 = sqrt(c * c + (d - x) * (d - x)); return d1 + d2; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> a >> b >> c >> d; ld p = findMinReal(0, 1e4, f); printf("%.10llf\n", p); }