結果
問題 |
No.1189 Sum is XOR
|
ユーザー |
|
提出日時 | 2022-12-31 19:14:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 342 ms / 2,000 ms |
コード長 | 1,197 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 117,504 KB |
最終ジャッジ日時 | 2024-11-26 18:20:12 |
合計ジャッジ時間 | 7,236 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) INF = float("INF") MOD = 10 ** 9 + 7 MOD2 = 998244353 from heapq import heappop, heappush import math from collections import Counter, deque from itertools import accumulate, combinations, combinations_with_replacement, permutations from bisect import bisect_left, bisect_right import decimal def inv(a, p): x = a f = p - 2 ret = 1 while f > 1: if f % 2 == 0: x = x * x % p f //= 2 else: ret *= x ret %= p f -= 1 ret *= x ret %= p return ret n, k = map(int, input().split()) a = list(map(int, input().split())) d = dict() for i in a: if i not in d: d[i] = 0 d[i] += 1 if k > 10: print(0) else: dp = [[0] * 1024 for _ in range(k + 1)] dp[0][0] = 1 for i in range(k): for j in range(1024): for l in d: if j & l == 0: dp[i + 1][j | l] += dp[i][j] * d[l] % MOD2 ans = 0 for i in range(1024): ans += dp[-1][i] ans %= MOD2 for i in range(1, k + 1): ans *= inv(i, MOD2) ans %= MOD2 print(ans)