結果

問題 No.250 atetubouのzetubou
ユーザー not_522
提出日時 2015-08-04 11:53:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 2,308 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 164,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 01:13:27
合計ジャッジ時間 5,695 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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;
}
}
return accumulate(a.begin(), a.end(), T(1), multiplies<T>());
}
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 = 1; i <= d + x - 1; ++i) sum += log(i);
for (int i = 1; i <= x; ++i) sum -= log(i);
for (int i = 1; i <= d - 1; ++i) sum -= log(i);
if (sum > limit + 1) {
cout << "ZETUBOU" << endl;
continue;
}
long long s = comb.combination(d + x - 1, x);
cout << (s <= t ? "AC" : "ZETUBOU") << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0