QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754812 | #4825. Even and Odd Combinations | supepapupu | 0 | 0ms | 0kb | Python3 | 1.2kb | 2024-11-16 15:51:55 | 2024-11-16 15:51:56 |
answer
fac = [1 for i in range(51)]
for i in range(1, 51): fac[i] = fac[i] * fac[i - 1]
def binom(a, b):
if b < 0: return 0
return fac[a] // fac[b] // fac[a - b]
def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
if n & 1:
print(n, n - k)
b = []
for i in range(1, n + 1):
if not i in a:
b.append(i)
print(" ".join(list(map(str, b))))
return
tot = 0
for i in range(k & 1, k, 2):
tot += binom(n, i)
cnt = 0
for i in range(1, n + 1):
if i in a:
cnt += 1
else:
tot += binom(n - i, k - cnt - 1)
for i in range(~k & 1, n + 1, 2):
if tot > binom(n, i):
tot -= binom(n, i)
continue
cnt = 0
b = []
for j in range(1, n + 1):
if tot > binom(n - j, i - cnt - 1):
tot -= binom(n - j, i - cnt - 1)
continue
b.append(j)
cnt += 1
break
print(n, len(b))
print(" ".join(list(map(str, b))))
T = int(input())
for _ in range(T):
solve()
詳細信息
Test #1:
score: 0
Stage 1: Program answer Runtime Error
input:
6 3 0 2 1 1 3 3 1 2 3 3 1 1 3 1 2 3 1 3