Submission #18583997
Source Code Expand
Copy
// #define LOCAL #define _USE_MATH_DEFINES #include <array> #include <cassert> #include <cstdio> #include <cstring> #include <iostream> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <queue> #include <stack> #include <list> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <algorithm> #include <complex> #include <cmath> #include <numeric> #include <bitset> #include <functional> #include <random> #include <ctime> using namespace std; template <typename A, typename B> ostream& operator <<(ostream& out, const pair<A, B>& a) { out << "(" << a.first << "," << a.second << ")"; return out; } template <typename T, size_t N> ostream& operator <<(ostream& out, const array<T, N>& a) { out << "["; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]"; return out; } template <typename T> ostream& operator <<(ostream& out, const vector<T>& a) { out << "["; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]"; return out; } template <typename T, class Cmp> ostream& operator <<(ostream& out, const set<T, Cmp>& a) { out << "{"; bool first = true; for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}"; return out; } template <typename U, typename T, class Cmp> ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) { out << "{"; bool first = true; for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}"; return out; } #ifdef LOCAL #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 42 #endif template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } typedef long long int64; typedef pair<int, int> ii; #define SZ(x) (int)((x).size()) template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2; const int MOD = 1e9 + 7; mt19937 mrand(random_device{}()); int rnd(int x) { return mrand() % x; } struct fast_ios { fast_ios() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); }; } fast_ios_; const int N = 5e6 + 10; int fact[N], ifact[N], inv[N]; struct comb_init { comb_init() { inv[1] = 1; for (int i = 2; i < N; ++i) { inv[i] = (MOD - MOD / i) * (int64)inv[MOD % i] % MOD; } fact[0] = ifact[0] = 1; for (int i = 1; i < N; ++i) { fact[i] = (int64)fact[i - 1] * i % MOD; ifact[i] = (int64)ifact[i - 1] * inv[i] % MOD; } } } comb_init_; int64 comb(int n, int m) { if (n < m || m < 0) return 0; return (int64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD; } int main() { int n, m; cin >> n >> m; m += n; vector<int> a(n); int sum = n; for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i]; int ret = 1; trace(m, sum); for (int i = 0; i < sum; ++i) ret = 1LL * ret * (m - i) % MOD; ret = 1LL * ret * ifact[sum] % MOD; cout << ret << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Binomial Coefficient is Fun |
User | cuiaoxiang |
Language | C++ (Clang 10.0.0) |
Score | 600 |
Code Size | 3407 Byte |
Status | AC |
Exec Time | 136 ms |
Memory | 61796 KB |
Compile Error
./Main.cpp:78:42: warning: unused variable 'inf' [-Wunused-const-variable] template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2; ^ 1 warning generated.
Judge Result
Set Name | All | Sample | ||||
---|---|---|---|---|---|---|
Score / Max Score | 600 / 600 | 0 / 0 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
All | sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_31.txt, testcase_32.txt, testcase_33.txt, testcase_34.txt, testcase_35.txt, testcase_36.txt, testcase_37.txt, testcase_38.txt, testcase_39.txt, testcase_4.txt, testcase_40.txt, testcase_41.txt, testcase_42.txt, testcase_43.txt, testcase_44.txt, testcase_45.txt, testcase_46.txt, testcase_47.txt, testcase_48.txt, testcase_49.txt, testcase_5.txt, testcase_50.txt, testcase_51.txt, testcase_52.txt, testcase_53.txt, testcase_54.txt, testcase_55.txt, testcase_56.txt, testcase_57.txt, testcase_58.txt, testcase_59.txt, testcase_6.txt, testcase_60.txt, testcase_61.txt, testcase_62.txt, testcase_63.txt, testcase_64.txt, testcase_65.txt, testcase_66.txt, testcase_67.txt, testcase_68.txt, testcase_69.txt, testcase_7.txt, testcase_70.txt, testcase_8.txt, testcase_9.txt |
Sample | sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 124 ms | 61776 KB |
sample_02.txt | AC | 117 ms | 61696 KB |
testcase_1.txt | AC | 114 ms | 61736 KB |
testcase_10.txt | AC | 135 ms | 61652 KB |
testcase_11.txt | AC | 132 ms | 61744 KB |
testcase_12.txt | AC | 136 ms | 61632 KB |
testcase_13.txt | AC | 130 ms | 61764 KB |
testcase_14.txt | AC | 126 ms | 61652 KB |
testcase_15.txt | AC | 126 ms | 61704 KB |
testcase_16.txt | AC | 130 ms | 61660 KB |
testcase_17.txt | AC | 124 ms | 61624 KB |
testcase_18.txt | AC | 126 ms | 61700 KB |
testcase_19.txt | AC | 124 ms | 61664 KB |
testcase_2.txt | AC | 121 ms | 61732 KB |
testcase_20.txt | AC | 123 ms | 61704 KB |
testcase_21.txt | AC | 126 ms | 61704 KB |
testcase_22.txt | AC | 130 ms | 61616 KB |
testcase_23.txt | AC | 125 ms | 61608 KB |
testcase_24.txt | AC | 127 ms | 61796 KB |
testcase_25.txt | AC | 126 ms | 61704 KB |
testcase_26.txt | AC | 131 ms | 61616 KB |
testcase_27.txt | AC | 126 ms | 61660 KB |
testcase_28.txt | AC | 126 ms | 61652 KB |
testcase_29.txt | AC | 124 ms | 61636 KB |
testcase_3.txt | AC | 118 ms | 61612 KB |
testcase_30.txt | AC | 128 ms | 61700 KB |
testcase_31.txt | AC | 125 ms | 61608 KB |
testcase_32.txt | AC | 123 ms | 61712 KB |
testcase_33.txt | AC | 129 ms | 61768 KB |
testcase_34.txt | AC | 122 ms | 61756 KB |
testcase_35.txt | AC | 128 ms | 61652 KB |
testcase_36.txt | AC | 124 ms | 61632 KB |
testcase_37.txt | AC | 127 ms | 61764 KB |
testcase_38.txt | AC | 127 ms | 61608 KB |
testcase_39.txt | AC | 129 ms | 61764 KB |
testcase_4.txt | AC | 117 ms | 61704 KB |
testcase_40.txt | AC | 123 ms | 61772 KB |
testcase_41.txt | AC | 125 ms | 61752 KB |
testcase_42.txt | AC | 126 ms | 61628 KB |
testcase_43.txt | AC | 125 ms | 61768 KB |
testcase_44.txt | AC | 129 ms | 61740 KB |
testcase_45.txt | AC | 122 ms | 61632 KB |
testcase_46.txt | AC | 129 ms | 61740 KB |
testcase_47.txt | AC | 127 ms | 61652 KB |
testcase_48.txt | AC | 125 ms | 61628 KB |
testcase_49.txt | AC | 126 ms | 61768 KB |
testcase_5.txt | AC | 116 ms | 61704 KB |
testcase_50.txt | AC | 128 ms | 61620 KB |
testcase_51.txt | AC | 132 ms | 61632 KB |
testcase_52.txt | AC | 127 ms | 61660 KB |
testcase_53.txt | AC | 130 ms | 61704 KB |
testcase_54.txt | AC | 117 ms | 61712 KB |
testcase_55.txt | AC | 112 ms | 61716 KB |
testcase_56.txt | AC | 117 ms | 61744 KB |
testcase_57.txt | AC | 121 ms | 61760 KB |
testcase_58.txt | AC | 116 ms | 61632 KB |
testcase_59.txt | AC | 120 ms | 61788 KB |
testcase_6.txt | AC | 117 ms | 61648 KB |
testcase_60.txt | AC | 116 ms | 61720 KB |
testcase_61.txt | AC | 126 ms | 61764 KB |
testcase_62.txt | AC | 127 ms | 61760 KB |
testcase_63.txt | AC | 127 ms | 61796 KB |
testcase_64.txt | AC | 128 ms | 61760 KB |
testcase_65.txt | AC | 124 ms | 61704 KB |
testcase_66.txt | AC | 123 ms | 61760 KB |
testcase_67.txt | AC | 128 ms | 61612 KB |
testcase_68.txt | AC | 128 ms | 61612 KB |
testcase_69.txt | AC | 122 ms | 61708 KB |
testcase_7.txt | AC | 118 ms | 61624 KB |
testcase_70.txt | AC | 125 ms | 61612 KB |
testcase_8.txt | AC | 125 ms | 61648 KB |
testcase_9.txt | AC | 132 ms | 61764 KB |