結果

問題 No.550 夏休みの思い出(1)
ユーザー mdj982mdj982
提出日時 2018-03-10 20:44:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,460 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 108,372 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 18:26:38
合計ジャッジ時間 2,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
5,248 KB
testcase_01 AC 12 ms
5,376 KB
testcase_02 AC 13 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 13 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 12 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 13 ms
5,376 KB
testcase_31 AC 13 ms
5,376 KB
testcase_32 AC 12 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 14 ms
5,376 KB
testcase_40 AC 13 ms
5,376 KB
testcase_41 AC 13 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 13 ms
5,376 KB
testcase_49 WA -
testcase_50 AC 1 ms
5,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 12 ms
5,376 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>

using namespace std;

#define INFD numeric_limits<double>::infinity()
#define INFL (int)1e8
#define INFLL (long long)1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define rnd(d) (int)((double)d + 0.5)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/



vll divisors(ll x) {
  vll ret;
  Loopll1(i, x) {
    if (i > 1e6) break;
    ll y = (ll)i * i;
    if (y >= x) {
      if (y == x) ret.push_back(i);
      break;
    }
    else {
      if (x % i == 0) {
        ret.push_back(i);
        ret.push_back(x / i);
      }
    }
  }
  return ret;
}

inline ll calc(ll a, ll b, ll c, ll x) {
  return x * (x * (x + a) + b) + c;
}

inline ll calc2(ll a, ll b, ll x) {
  return x * (x + a) + b;
}

int main() {
  ll a, b, c; cin >> a >> b >> c;
  vll ans;
  if (c == 0) {
    ans.push_back(0);
  }
  else {
    vll c_divs = divisors(abs(c));
    Loop(i, c_divs.size()) {
      if (calc(a, b, c, c_divs[i]) == 0) {
        ans.push_back(c_divs[i]);
        break;
      }
      if (calc(a, b, c, -c_divs[i]) == 0) {
        ans.push_back(-c_divs[i]);
        break;
      }
    }
    a += ans[0];
    b += a * ans[0];
    c += b * ans[0];
  }
  ans.push_back(rnd((-a + sqrt(a * a - 4 * b)) / 2));
  ans.push_back(rnd((-a - sqrt(a * a - 4 * b)) / 2));
  sort(ans.begin(), ans.end());
  Loop(i, ans.size()) {
    if (i > 0 && ans[i] == ans[i - 1]) continue;
    cout << ans[i] << " ";
  }
  cout << endl;
}
0