結果

問題 No.250 atetubouのzetubou
ユーザー not_522not_522
提出日時 2015-08-04 11:34:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,211 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 149,900 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 01:00:11
合計ジャッジ時間 4,537 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template<typename T> inline T gcd(T a, T b) {
  return __gcd(a, b);
}

template<typename T> inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

template<typename T> inline T floor(T a, T b) {
  return a / b * b <= a ? a / b : 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);
}

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> class Combination {
private:
  vector<vector<T>> comb;
  
public:
  Combination(int n = 0) : comb(n, vector<T>(n, 0)) {
    for (int i = 0; i < n; ++i) comb[i][0] = 1;
    for (int i = 1; i < n; ++i) {
      for (int j = 1; j < n; ++j) {
        comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
      }
    }
  }

  T combination(int n, int m) {
    if (n < m) return 0;
    if (n < (int)comb.size()) return comb[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) {
    if (n < m) return 0;
    if (n < (int)comb.size()) return comb[n][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;
      }
    }
    T res = 1;
    for (auto i : a) res = res * i;
    return res;
  }

  T repetition(int n, int r) {
    return combination(n + r - 1, r);
  }
};

int main() {
  int q;
  cin >> q;
  Combination<long long> comb;
  for (int i = 0; i < q; ++i) {
    long long d, x, t;
    cin >> d >> x >> t;
    if (t == 0) {
      cout << "ZETUBOU" << endl;
      continue;
    }
    double sum = 0, limit = log(t);
    for (int i = x + 1; i <= d + x - 1; ++i) sum += log(i + 1);
    if (sum > limit * 2) {
      cout << "ZETUBOU" << endl;
      continue;
    }
    int s = comb.combination(d + x - 1, x);
    cout << (s <= t ? "AC" : "ZETUBOU") << endl;
  }
}
0