QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507126 | #9112. Zayin and Raffle | IllusionaryDominance | RE | 0ms | 0kb | C++14 | 1.9kb | 2024-08-06 11:17:58 | 2024-08-06 11:17:59 |
answer
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 10;
const int M = (1 << 16) + 10;
const int K = (1 << 8) + 10;
long long ksm(long long x, long long y){
long long re = 1;
for (; y; y >>= 1){
if(y & 1) re = re * x % MOD;
x = x * x % MOD;
}
return re;
}
const long long dv = ksm(1e9, MOD - 2);
long long tot[M][K], p[K], ans[M];
int main(){
ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
freopen("1.txt", "r", stdin);
freopen("2.txt", "w", stdout);
int n, m, k;
cin >> n >> m >> k;
for (int i = 0; i < k; ++ i){
long long _p; cin >> _p, _p = _p * dv % MOD;
for (int j = (1 << i); j < (1 << k); j = ((j + 1) | (1 << i))) p[j] += _p;
}
for (int i = 0; i < (1 << m); ++ i) ans[i] = 1;
for (int i = 1; i <= n; ++ i){
vector<int> a(k);
for (int j = 0; j < k; ++ j) cin >> a[j];
for (int j = 0; j < (1 << k); ++ j){
int S = 0;
for (int l = 0; l < k; ++ l) if((j >> l) & 1) S |= a[l];
++ tot[S][j];
}
}
for (int S = 0; S < (1 << m); ++ S)
for (int i = 0; i < k; ++ i)
for (int s = 0; s < (1 << k); ++ s) if((s >> i) & 1) (tot[S][s ^ (1 << i)] += MOD - tot[S][s]) %= MOD;
for (int S = 0; S < (1 << k); ++ S)
for (int i = 0; i < m; ++ i)
for (int s = 0; s < (1 << m); ++ s) if((s >> i) & 1) (tot[s][S] += tot[s ^ (1 << i)][S]) %= MOD;
for (int i = 0; i < (1 << k); ++ i)
for (int j = 0; j < (1 << m); ++ j)
(ans[j] *= ksm(p[i], tot[j][i])) %= MOD;
for (int i = 0; i < m; ++ i)
for (int s = 0; s < (1 << m); ++ s) if((s >> i) & 1) (ans[s] += MOD - ans[s ^ (1 << i)]) %= MOD;
for (int i = 0; i < (1 << m); ++ i) cout << ans[i] << "\n";
}
/*
2 2 2
400000000 600000000
1 0
2 1
*/
詳細信息
Test #1:
score: 0
Dangerous Syscalls
input:
100000 16 8 14837 17850 15180 22820 26722 4874 4574 999893143 15006 45877 19815 26604 6797 0 25449 15769 26395 0 495 64118 18133 47822 5863 39708 56443 188 55498 14620 36924 25033 0 36587 55421 21544 59411 3280 55222 0 51028 55986 42323 41153 53683 16144 53188 15759 0 28378 63709 51900 0 18592 1916 ...