結果
問題 | No.1554 array_and_me |
ユーザー | 沙耶花 |
提出日時 | 2021-06-18 21:49:22 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,427 bytes |
コンパイル時間 | 4,576 ms |
コンパイル使用メモリ | 267,708 KB |
実行使用メモリ | 13,408 KB |
最終ジャッジ日時 | 2023-09-04 22:47:19 |
合計ジャッジ時間 | 8,849 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
11,520 KB |
testcase_01 | AC | 42 ms
11,544 KB |
testcase_02 | AC | 42 ms
11,592 KB |
testcase_03 | AC | 42 ms
11,440 KB |
testcase_04 | AC | 42 ms
11,616 KB |
testcase_05 | AC | 42 ms
11,456 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 59 ms
13,048 KB |
testcase_12 | AC | 59 ms
13,076 KB |
testcase_13 | AC | 59 ms
13,200 KB |
testcase_14 | AC | 60 ms
13,256 KB |
testcase_15 | AC | 60 ms
13,260 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 67 ms
11,652 KB |
testcase_37 | AC | 66 ms
11,840 KB |
testcase_38 | AC | 66 ms
11,676 KB |
testcase_39 | AC | 64 ms
11,736 KB |
testcase_40 | AC | 65 ms
11,800 KB |
testcase_41 | AC | 41 ms
11,552 KB |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 struct combi{ deque<mint> kaijou; deque<mint> kaijou_; combi(int n){ kaijou.push_back(1); for(int i=1;i<=n;i++){ kaijou.push_back(kaijou[i-1]*i); } mint b=kaijou[n].inv(); kaijou_.push_front(b); for(int i=1;i<=n;i++){ int k=n+1-i; kaijou_.push_front(kaijou_[0]*k); } } mint combination(int n,int r){ if(r>n)return 0; mint a = kaijou[n]*kaijou_[r]; a *= kaijou_[n-r]; return a; } mint junretsu(int a,int b){ mint x = kaijou_[a]*kaijou_[b]; x *= kaijou[a+b]; return x; } mint catalan(int n){ return combination(2*n,n)/(n+1); } }; combi C(1000000); void solve(){ int N,K; cin>>N>>K; vector<int> A(N); int S = 0; rep(i,N){ cin>>A[i]; S += A[i]; } vector<int> v(N); priority_queue<pair<int,int>> Q; int sum = 0; rep(i,N){ int t = A[i] * K; v[i] = t / S; Q.emplace(t%S,i); sum += v[i]; } while(sum != K){ sum ++; v[Q.top().second]++; Q.pop(); } mint ans = 1; int n = K; rep(i,N){ //cout<<v[i]<<','; mint p = A[i]; p /= S; ans *= p.pow(v[i]); ans *= C.combination(n,v[i]); n -= v[i]; } cout<<ans.val()<<endl; } int main(){ int _T; cin>>_T; rep(_,_T){ solve(); } return 0; }