比赛 |
2025.10.18 |
评测结果 |
AAAAAAAAAA |
题目名称 |
01数列 |
最终得分 |
100 |
用户昵称 |
淮淮清子 |
运行时间 |
0.034 s |
代码语言 |
C++ |
内存使用 |
3.71 MiB |
提交时间 |
2025-10-18 09:09:34 |
显示代码纯文本
#include<iostream>
using namespace std;
const int MOD = 1e9 + 7;
long long n, c0 = 0, c1 = 0;
bool f[1005];
long long C[1005], ans = 0;
long long qpow(long long k){
long long res = 1, a = 2;
while(k){
if(k & 1) res = res * a % MOD;
a = a * a % MOD;
k >>= 1;
}
return res;
}
int main(){
freopen("01.in", "r", stdin);
freopen("01.out", "w", stdout);
cin.tie(0); ios::sync_with_stdio(0);
cin >> n;
for(int i = 1;i <= n;i ++){
cin >> f[i];
if(f[i]) c1 ++;
else c0 ++;
}
C[0] = 1;
for(int i = 1;i <= n;i ++){
for(int j = i;j >= 1;j --){
C[j] = (C[j] + C[j - 1]) % MOD;
}
}
for(int m = 0;m <= n;m ++){
long long cnt = 1ll * c0 * (n - m) + 1ll * c1 * m;
ans = (ans + C[m] * qpow(cnt)) % MOD;
}
cout << ans << '\n';
return 0;
}