結果
問題 | No.766 金魚すくい |
ユーザー | firiexp |
提出日時 | 2019-08-26 20:45:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 39 ms / 1,500 ms |
コード長 | 3,269 bytes |
コンパイル時間 | 1,071 ms |
コンパイル使用メモリ | 104,248 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-27 15:45:05 |
合計ジャッジ時間 | 3,460 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 35 ms
6,940 KB |
testcase_24 | AC | 35 ms
6,940 KB |
testcase_25 | AC | 38 ms
6,940 KB |
testcase_26 | AC | 36 ms
6,944 KB |
testcase_27 | AC | 37 ms
6,940 KB |
testcase_28 | AC | 34 ms
6,940 KB |
testcase_29 | AC | 35 ms
6,944 KB |
testcase_30 | AC | 35 ms
6,940 KB |
testcase_31 | AC | 39 ms
6,944 KB |
testcase_32 | AC | 36 ms
6,940 KB |
testcase_33 | AC | 29 ms
6,940 KB |
testcase_34 | AC | 29 ms
6,944 KB |
testcase_35 | AC | 4 ms
6,944 KB |
testcase_36 | AC | 4 ms
6,944 KB |
testcase_37 | AC | 37 ms
6,940 KB |
testcase_38 | AC | 38 ms
6,940 KB |
testcase_39 | AC | 39 ms
6,940 KB |
testcase_40 | AC | 37 ms
6,944 KB |
testcase_41 | AC | 30 ms
6,940 KB |
testcase_42 | AC | 28 ms
6,940 KB |
testcase_43 | AC | 1 ms
6,944 KB |
testcase_44 | AC | 1 ms
6,944 KB |
ソースコード
#include <limits> #include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; template <ll M = MOD> struct modint { ll val; modint(const ll x = 0) : val(x) { val = x; while(val < 0) val += M; while(val > M) val -= M; } modint operator+(const modint a) const { return modint(*this) += a; } modint operator-(const modint a) const { return modint(*this) -= a; } modint operator*(const modint a) const { return modint(*this) *= a; } modint operator/(const modint a) const { return modint(*this) /= a; } modint operator-() const { return modint(M-val); } modint inv() const { ll u = 1, v = 0, s = 0, t = 1, m = M, x = val; while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); } if(s < 0) s += M; return modint(s); } modint pow(ll n) const { ll u = 1, xx = val; while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; } return modint(u); } modint& operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; } modint& operator-=(const modint a){ val -= a.val; if(val < 0) val += M; return *this; } modint& operator*=(const modint a){ val = val * a.val % M; return *this; } modint& operator/=(const modint a){ val = val * a.inv().val % M; return *this;} modint& operator=(const int& x){ val = x; while(val < 0) val += M; while(val > M) val -= M; return *this; } }; class Factorial { using mint = modint<MOD>; vector<mint> facts, factinv; public: explicit Factorial(int n) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)) { facts[0] = 1; for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*mint(i); factinv[n] = facts[n].inv(); for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * mint(i+1); } mint fact(int k) const { if(k >= 0) return facts[k]; else return factinv[-k]; } mint operator[](const int &k) const { if(k >= 0) return facts[k]; else return factinv[-k]; } mint C(int p, int q) const { if(q < 0 || p < q) return 0; return facts[p] * factinv[q] * factinv[p-q]; } mint P(int p, int q) const { if(q < 0 || p < q) return 0; return facts[p] * factinv[p-q]; } mint H(int p, int q) const { if(p < 0 || q < 0) return 0; return q == 0 ? 1 : C(p+q-1, q); } }; using mint = modint<MOD>; int main() { int n, m, P; cin >> n >> m >> P; mint p = mint(P)*(mint(100).inv()); Factorial f(n+m); vector<int> v(n); for (auto &&i : v) scanf("%d", &i); sort(v.begin(),v.end(), greater<>()); mint s = 0, ans = 0, val = 1; for (int i = 0; i < n; ++i) { mint pr = (mint(1)-p).pow(i)*f.H(m, i)*p.pow(m); val -= pr; ans += pr*s; s += mint(v[i]); } cout << (ans + val*s).val << "\n"; return 0; }