結果

問題 No.550 夏休みの思い出(1)
ユーザー snrnsidysnrnsidy
提出日時 2021-07-15 21:13:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,266 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 199,688 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 05:57:37
合計ジャッジ時間 4,158 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:66:52:
/usr/local/gcc7/include/c++/12.2.0/ostream:233:25: 警告: ‘res[2]’ may be used uninitialized [-Wmaybe-uninitialized]
  233 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:17:17: 備考: ‘res[2]’ はここで定義されています
   17 |     long double res[3];
      |                 ^~~
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:66:35:
/usr/local/gcc7/include/c++/12.2.0/ostream:233:25: 警告: ‘res[1]’ may be used uninitialized [-Wmaybe-uninitialized]
  233 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:17:17: 備考: ‘res[1]’ はここで定義されています
   17 |     long double res[3];
      |                 ^~~
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:66:18:
/usr/local/gcc7/include/c++

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

long long int A, B, C;
long double f(long double x)
{
    return x * x * x + A * x * x + B * x + C;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    cin >> A >> B >> C;
    long double res[3];
    long double p0 = (-A - sqrt(A * A - 3 * B)) / 3;
    long double p1 = (-A + sqrt(A * A - 3 * B)) / 3;
    long double lo = -1e9;
    long double hi = p0;
    for(int i=0;i<200;i++)
    {
        long double mid = (lo + hi) / 2;
        if (f(mid) <= 0)
        {
            res[0] = mid;
            lo = mid + 1;
        }
        else
        {
            hi = mid - 1;
        }
    }
    lo = p0;
    hi = p1;
    for(int i=0;i<200;i++)
    {
        long double mid = (lo + hi) / 2;
        if (f(mid) >= 0)
        {
            res[1] = mid;
            lo = mid + 1;
        }
        else
        {
            hi = mid - 1;
        }
    }
    lo = p1;
    hi = 1e9;
    for(int i=0;i<200;i++)
    {
        long double mid = (lo + hi) / 2;
        if (f(mid) <= 0)
        {
            res[2] = mid;
            lo = mid + 1;
        }
        else
        {
            hi = mid - 1;
        }
    }

    cout << res[0] << ' ' << res[1] << ' ' << res[2] << '\n';
    return 0;
}
0