結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-05-29 23:48:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 742 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 18,084 KB |
最終ジャッジ日時 | 2024-11-06 08:59:33 |
合計ジャッジ時間 | 4,073 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 5 TLE * 1 -- * 18 |
ソースコード
from itertools import combinations N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) u = 1 for a in A: u *= a - 1 u %= 998244353 for b in B: if b > N / 2: result = 0 for c in combinations(A, N - b): t = 1 for i in c: t *= i - 1 t %= 998244353 result += t result %= 998244353 print(result) else: result = 0 for c in combinations(A, b): t = 1 for i in c: t *= i - 1 t %= 998244353 result += u * pow(t, 998244353 - 2, 998244353) result %= 998244353 print(result)