A
最大概率输的一定是最多人投的那个,模拟
code: …好像被我自己不小心删掉了…….
B
看不懂a
C
枚举2,4,8,9的个数后可以知道所有数的个数,预处理1+10+100+..1000..的和后直接算贡献
code:
class ProductAndSum {
public:
ll s[maxn];
int u2,u3,u5,u7,u;
ll pw(ll x,int k)
{
ll re=1ll;
for(;k;k>>=1,x=x*x%Mod) if(k&1)
re=re*x%Mod;
return re;
}
ll inv[maxn],pinv[maxn],p[maxn];
void pre()
{
s[1]=1ll;
for(int i=2,t=10ll;i<maxn;i++,t=t*10ll%Mod) s[i]=(s[i-1]+t)%Mod;
p[0]=1ll; for(ll i=1;i<maxn;i++) p[i]=p[i-1]*i%Mod;
pinv[maxn-1]=pw(p[maxn-1],Mod-2);
for(ll i=maxn-2;i>=0;i--) pinv[i]=pinv[i+1]*(i+1ll)%Mod;
for(ll i=1;i<maxn;i++) inv[i]=pinv[i]*p[i-1]%Mod;
}
ll C(int x,int y){return (ll)y*inv[x]%Mod;}
ll cal(int i2,int i4,int i8,int i9)
{
int i6=u2-i2-i4*2-i8*3;
int i3=u3-i6-i9*2;
int i1=u-i2*2-i3*3-i4*4-i6*6-i8*8-i9*9;
if(i1<0||i3<0||i6<0) return 0ll;
int n=i1+i2+i3+i4+u5+i6+u7+i8+i9;
ll re=0,tmp;
tmp=p[n]*pinv[i1]%Mod*pinv[i2]%Mod*pinv[i3]%Mod*pinv[i4]%Mod*pinv[u5]%Mod;
tmp=tmp*pinv[i6]%Mod*pinv[u7]%Mod*pinv[i8]%Mod*pinv[i9]%Mod;
tmp=tmp*s[n]%Mod;
if(i1) (re+=tmp*C(n,i1)%Mod)__;
if(i2) (re+=tmp*2ll%Mod*C(n,i2)%Mod)__;
if(i3) (re+=tmp*3ll%Mod*C(n,i3)%Mod)__;
if(i4) (re+=tmp*4ll%Mod*C(n,i4)%Mod)__;
if(u5) (re+=tmp*5ll%Mod*C(n,u5)%Mod)__;
if(i6) (re+=tmp*6ll%Mod*C(n,i6)%Mod)__;
if(u7) (re+=tmp*7ll%Mod*C(n,u7)%Mod)__;
if(i8) (re+=tmp*8ll%Mod*C(n,i8)%Mod)__;
if(i9) (re+=tmp*9ll%Mod*C(n,i9)%Mod)__;
return re;
}
int getSum(int p2, int p3, int p5, int p7, int S) {
u=S;
u2=p2; u3=p3; u5=p5; u7=p7;
u-=u5*5+u7*7;
if(u<0) return 0;
pre();
ll re=0;
for(int i2=0;i2<=p2;i2++) for(int i4=0;i4*2+i2<=p2;i4++) for(int i8=0;i8*3+i4*2+i2<=p2;i8++)
for(int i9=0;i9*2<=p3;i9++)
(re+=cal(i2,i4,i8,i9))__;
return re;
}
};