結果

問題 No.550 夏休みの思い出(1)
ユーザー ei1333333
提出日時 2017-07-28 23:18:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 173,456 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-10 04:58:41
合計ジャッジ時間 54,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:37:8: warning: use of an operand of type 'bool' in 'operator++' is deprecated [-Wdeprecated]
   37 |     if(first++) cout << " ";
      |        ^~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int main()
{
  int64 A, B, C;
  cin >> A >> B >> C;

  auto f = [&](auto x)
  {
    return (x * x * x + A * x * x + B * x + C);
  };

  set< int64 > vs;

  double shift = 1e6;
  double shift2 = 2e5;

  for(double low = -1000000001; low <= 1000000001; low += shift) {
    double high = low + shift;
    for(int i = 0; i < 100; i++) {
      double left = (low * 2 + high) / 3;
      double right = (low + high * 2) / 3;
      if(abs(f(left)) < abs(f(right))) high = right;
      else low = left;
    }
    for(int64 j = low - shift2; j <= low + shift2; j++) {
      if(f(j) == 0) vs.emplace(j);
    }
  }

  bool first = false;
  for(auto &s : vs) {
    if(first++) cout << " ";
    cout << s;
  }
  cout << endl;

}

0