結果

問題 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,967 ms
コンパイル使用メモリ 200,856 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 22:16:31
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,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 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,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 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In member function '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:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:233:25: warning: 'res[2]' may be used uninitialized [-Wmaybe-uninitialized]
  233 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:17:17: note: 'res[2]' was declared here
   17 |     long double res[3];
      |                 ^~~
In member function '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:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:233:25: warning: 'res[1]' may be used uninitialized [-Wmaybe-uninitialized]
  233 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:17:17: note: 'res[1]' was declared here
   17 |     long double res[3];
      |                 ^~~
In member function '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

ソースコード

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