AC代码:
#include<cstdio>
#include<cstring>
typedef long long LL;
const LL mod=1e9+7;
int main()
{
LL a[15],p[55],T,N;
p[0]=1;
for(LL i=1;i<=50;i++)
p[i]=p[i-1]*2%mod;
while(~scanf("%lld",&T))
{
while(T--)
{
scanf("%lld",&N);
memset(a,0,sizeof(a));
for(LL k=1;k<=N;k++)
{
LL t;
scanf("%lld",&t);
a[t]++;
}
LL cnt=1<<10;
LL ans=0;
for(LL j=1;j<cnt;j++)
{
LL times=1,total=0;
for(LL i=0;i<10;i++)
{
if((j>>i)&1)
{
times=times*(p[a[i+1]]-1)%mod;
total+=i+1;
}
}
ans=(ans+times*total%mod)%mod;
}
printf("%lld\n",ans);
}
}
return 0;
}