結果

問題 No.550 夏休みの思い出(1)
ユーザー mdj982mdj982
提出日時 2018-03-10 20:16:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,103 bytes
コンパイル時間 1,351 ms
コンパイル使用メモリ 106,816 KB
実行使用メモリ 12,240 KB
最終ジャッジ日時 2023-08-04 20:13:38
合計ジャッジ時間 8,396 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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 Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#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;
  Loop1(i, x) {
    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;
}

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

int main() {
  ll a, b, c; cin >> a >> b >> c;
  vll ans;
  if (c == 0) {
    ans.push_back(0);
    vll b_divs = divisors(abs(b));
    Loop(i, b_divs.size()) {
      if (calc(a, b, c, b_divs[i]) == 0) {
        ans.push_back(b_divs[i]);
      }
      if (calc(a, b, c, -b_divs[i]) == 0) {
        ans.push_back(-b_divs[i]);
      }
    }
  }
  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]);
      }
      if (calc(a, b, c, -c_divs[i]) == 0) {
        ans.push_back(-c_divs[i]);
      }
    }
  }
  sort(ans.begin(), ans.end());
  Loop(i, ans.size()) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
0