結果
問題 | No.766 金魚すくい |
ユーザー | 👑 jupiro |
提出日時 | 2020-01-16 17:18:33 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 367 ms / 1,500 ms |
コード長 | 2,861 bytes |
コンパイル時間 | 1,273 ms |
コンパイル使用メモリ | 123,684 KB |
実行使用メモリ | 125,116 KB |
最終ジャッジ日時 | 2023-09-06 03:28:09 |
合計ジャッジ時間 | 17,922 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 253 ms
122,952 KB |
testcase_01 | AC | 265 ms
123,096 KB |
testcase_02 | AC | 252 ms
122,952 KB |
testcase_03 | AC | 253 ms
123,120 KB |
testcase_04 | AC | 257 ms
123,248 KB |
testcase_05 | AC | 259 ms
122,948 KB |
testcase_06 | AC | 247 ms
122,948 KB |
testcase_07 | AC | 263 ms
122,936 KB |
testcase_08 | AC | 269 ms
123,004 KB |
testcase_09 | AC | 258 ms
123,084 KB |
testcase_10 | AC | 251 ms
122,952 KB |
testcase_11 | AC | 257 ms
123,044 KB |
testcase_12 | AC | 272 ms
123,008 KB |
testcase_13 | AC | 254 ms
123,092 KB |
testcase_14 | AC | 256 ms
123,272 KB |
testcase_15 | AC | 258 ms
123,052 KB |
testcase_16 | AC | 261 ms
122,964 KB |
testcase_17 | AC | 264 ms
123,112 KB |
testcase_18 | AC | 259 ms
123,076 KB |
testcase_19 | AC | 263 ms
122,996 KB |
testcase_20 | AC | 268 ms
122,960 KB |
testcase_21 | AC | 264 ms
123,196 KB |
testcase_22 | AC | 268 ms
123,276 KB |
testcase_23 | AC | 344 ms
125,116 KB |
testcase_24 | AC | 339 ms
124,836 KB |
testcase_25 | AC | 367 ms
124,820 KB |
testcase_26 | AC | 345 ms
124,632 KB |
testcase_27 | AC | 347 ms
124,972 KB |
testcase_28 | AC | 343 ms
124,828 KB |
testcase_29 | AC | 341 ms
124,836 KB |
testcase_30 | AC | 346 ms
124,876 KB |
testcase_31 | AC | 345 ms
124,820 KB |
testcase_32 | AC | 354 ms
124,772 KB |
testcase_33 | AC | 333 ms
124,840 KB |
testcase_34 | AC | 324 ms
124,896 KB |
testcase_35 | AC | 247 ms
123,020 KB |
testcase_36 | AC | 266 ms
123,016 KB |
testcase_37 | AC | 354 ms
124,936 KB |
testcase_38 | AC | 340 ms
124,836 KB |
testcase_39 | AC | 360 ms
124,768 KB |
testcase_40 | AC | 348 ms
124,872 KB |
testcase_41 | AC | 329 ms
124,828 KB |
testcase_42 | AC | 334 ms
124,964 KB |
testcase_43 | AC | 265 ms
123,060 KB |
testcase_44 | AC | 249 ms
123,004 KB |
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> #include <iomanip> #include <limits> #include <chrono> #include <random> #include <array> #include <unordered_map> #include <functional> #include <complex> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; struct mint { ll x; // typedef long long ll; mint(ll x = 0) :x((x% mod + mod) % mod) {} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } mint COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return mint(fac[n] * (finv[k] * finv[n - k] % mod) % mod); } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N, M, P; scanf("%lld %lld %lld", &N, &M, &P); COMinit(); mint p = mint(P) * mint(100).inv(); mint res = 0; mint tmp = 0; vector<ll> V(N); vector<mint> f(N + 1); mint sum_f = 0; vector<mint> sum_v(N + 1); for (ll i = 0; i < N; i++) cin >> V[i]; sort(V.rbegin(), V.rend()); for (ll i = 1; i <= N; i++) { f[i] = COM(i + M - 2, i - 1) * p.pow(M) * (mint(1) - p).pow(i - 1); sum_f += f[i]; sum_v[i] = sum_v[i - 1] + V[i - 1]; } for (ll i = 1; i <= N; i++) { res += f[i] * sum_v[i - 1]; } //cout << res.x << endl; res += sum_v[N] * (mint(1) - sum_f); cout << res.x << endl; return 0; }