比赛 |
2025.10.18 |
评测结果 |
AAAAAAAAAA |
题目名称 |
01数列 |
最终得分 |
100 |
用户昵称 |
梦那边的美好ME |
运行时间 |
0.027 s |
代码语言 |
C++ |
内存使用 |
3.85 MiB |
提交时间 |
2025-10-18 09:03:44 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll n,cnt;
ll p1,p2,p3,ex,base2;
ll ans;
ll mpow(ll a,ll b){
ll res=1;
a%=mod;
while (b>0){
if (b&1) res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
ll mnv(ll a){
return mpow(a,mod-2);
}
int main(){
freopen("01.in","r",stdin);
freopen("01.out","w",stdout);
// freopen("in.in","r",stdin);
// freopen("out.out","w",stdout);
scanf("%lld",&n);
for (ll i=1,x;i<=n;i++){
scanf("%lld",&x);
cnt+=x;
}
p1=mpow(2,(ll)n*cnt);
ex=n-2*cnt;
if (ex>=0){
base2=mpow(2,ex);
}else{
base2=mnv(mpow(2,-ex));
}
p3=mpow(1+base2,n);
ans=p1*p3%mod;
printf("%lld\n",ans);
return 0;
}