結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:45: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |             double dist2 = sqrt( xa*xa + (ya-y)*(ya-y2) ) + sqrt( xb*xb + (yb-y2)*(yb-y2) );
      |                                          ~~~^~~

ソースコード

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-y)*(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