第一种:
int dfs(int now,int tot)
{
if(tot>17)return 0;
if(now==15)
{
if(tot<17)return 0;
for(int i=1;i<=14;i++)mine2[i]=mine[i];
for(int i=1;i<=14;i++)crd2[i]=crd[i];
return check();
}
int ans=0;
for(int i=0;i<=(now<=12?4:1)-mine[now];i++)
{
crd[now]=i;
ans+=dfs(now+1,tot+i);
}
return ans;
}
100 分。
第二种:
int dfs(int now,int tot)
{
if(tot>17)return 0;
if(tot==17)
{
for(int i=1;i<=14;i++)mine2[i]=mine[i];
for(int i=1;i<=14;i++)crd2[i]=crd[i];
return check();
}
if(now==15)return 0;
int ans=0;
for(int i=0;i<=(now<=12?4:1)-mine[now];i++)
{
crd[now]=i;
ans+=dfs(now+1,tot+i);
}
return ans;
}