結果

問題 No.550 夏休みの思い出(1)
ユーザー mamekinmamekin
提出日時 2017-07-28 23:10:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,676 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 108,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 11:33:30
合計ジャッジ時間 2,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 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 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 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 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
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 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 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 1 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const long long INF = LLONG_MAX / 2;
const int MAX = 1000000000;

long long getVal(const vector<long long>& coef, int x)
{
    double tmp = 0.0;
    for(int i=coef.size()-1; i>=0; --i){
        tmp *= x;
        tmp += coef[i];
    }

    if(tmp < -INF)
        return -INF;
    if(tmp > INF)
        return INF;

    long long ans = 0;
    for(int i=coef.size()-1; i>=0; --i){
        ans *= x;
        ans += coef[i];
    }
    return ans;
}

int main()
{
    vector<long long> coef(4);
    coef[3] = 1;
    for(int i=2; i>=0; --i)
        cin >> coef[i];

    int left = -MAX;
    int right = MAX;
    while(left < right){
        int mid = (left + right + 1) / 2;
        long long tmp = getVal(coef, mid);
        if(tmp <= 0)
            left = mid;
        else
            right = mid - 1;
    }

    vector<int> ans(1, left);
    double a = coef[2] + (double)ans[0];
    double b = -coef[0] / (double)ans[0];
    double x1 = (-a - sqrt(a*a - 4*b)) / 2;
    double x2 = (-a + sqrt(a*a - 4*b)) / 2;
    ans.push_back((int) round(x1));
    ans.push_back((int) round(x2));

    sort(ans.begin(), ans.end());
    cout << ans[0];
    for(int i=1; i<3; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}
0