結果

問題 No.306 さいたま2008
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-10-22 13:53:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,278 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 79,848 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 10:15:31
合計ジャッジ時間 1,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    double X[12] = { 100, 10, 1, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001, 0.00000001, 0.000000001 };
    double xa,ya,xb,yb;
    cin >> xa >> ya >> xb >> yb;
    
    double ans = 0;
    
    for ( int i = 0; i < 12; i++ ) {
        
        double dist;
        double y;
        dist = 1000000;
        for ( int j = 0; j < 10; j++ ) {
            
            double y1 = ans + X[i]*j;
            double y2 = ans - X[i]*j;
            
            double dist1 = sqrt( xa*xa + (ya-y1)*(ya-y1) ) + sqrt( xb*xb + (yb-y1)*(yb-y1) );
            double dist2 = sqrt( xa*xa + (ya-y2)*(ya-y2) ) + sqrt( xb*xb + (yb-y2)*(yb-y2) );
            
            if ( dist > dist1 ) {
                dist = dist1;
                y = y1;
            }
            if ( dist > dist2 ) {                
                dist = dist2;
                y = y2;
            }
        }
        
        ans = y;
    }
    
    printf( "%.9f", ans );
    
    return 0;
}
0