結果

問題 No.420 mod2漸化式
ユーザー not_522not_522
提出日時 2016-12-17 11:45:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 3,004 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 167,028 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 00:43:47
合計ジャッジ時間 2,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline T gcd(T t) {
  return t;
}

template<typename T, typename... S> inline T gcd(T t, S... s) {
  return __gcd(t, gcd(s...));
}

template<typename T> inline T lcm(T t) {
  return t;
}

template<typename T, typename... S> inline T lcm(T t, S... s) {
  T l = lcm(s...);
  return t / gcd(t, l) * l;
}

template<typename T> inline T floor(T a, T b) {
  return a / b * b <= a ? a / b : a / b - 1;
}

template<> inline float floor(float a, float b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<> inline double floor(double a, double b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<> inline long double floor(long double a, long double b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<typename T> inline T ceil(T a, T b) {
  return floor(a + b - 1, b);
}

template<typename T> inline T round(T a, T b) {
  return floor(a + b / 2, b);
}

template<typename T> inline T mod(T a, T b) {
  return a - floor(a, b) * b;
}

template<typename T> inline T factorial(T n) {
  return n <= 1 ? 1 : factorial(n - 1) * n;
}

template<typename T> inline T square(T n) {
  return n * n;
}

template<typename T> inline T cube(T n) {
  return n * n * n;
}

template<typename T> inline T norm(T x1, T y1, T x2, T y2) {
  return square(x1 - x2) + square(y1 - y2);
}

inline long long sqrt(long long n) {
  return sqrt((long double)n);
}

template<typename T> class Combination {
private:
  vector<T> factorial;

public:
  Combination(int n = 0) : factorial(n + 1, 1) {
    for (int i = 1; i <= n; ++i) factorial[i] = factorial[i - 1] * i;
  }

  T partial_permutation(int n, int m) {
    if (n < m) return 0;
    if (n < (int)factorial.size()) return factorial[n] / factorial[n - m];
    T res = 1;
    for (int i = n; i > n - m; --i) res *= i;
    return res;
  }

  T combination(int n, int m) {
    if (n < m) return 0;
    if (n < (int)factorial.size()) return factorial[n] / factorial[m] / factorial[n - m];
    T res = 1;
    for (int i = 0; i < min(m, n - m); ++i) res = res * (n - i) / (i + 1);
    return res;
  }

  T combination_safety(int n, int m) {
    m = min(m, n - m);
    vector<int> a(m), b(m);
    iota(a.begin(), a.end(), n - m + 1);
    iota(b.begin(), b.end(), 1);
    for (auto i : b) {
      for (auto& j : a) {
        auto g = gcd(i, j);
        i /= g;
        j /= g;
        if (i == 1) break;
      }
    }
    return accumulate(a.begin(), a.end(), T(1), multiplies<T>());
  }

  T repetition(int n, int m) {
    if (m == 0) return 1;
    return combination(n + m - 1, m);
  }
};

int main() {
  Combination<int64_t> comb;
  int x;
  cin >> x;
  if (x) cout << comb.combination(31, x) << " " << INT_MAX * comb.combination(30, x - 1) << endl;
  else cout << 1 << " " << 0 << endl;
}
0