版本比较
AT_abc193_d [ABC193D] Poker-题解
正文
增加 12 行删除 14 行
8 行未改动91011121314151613141518161718192024 行未改动454647485149505351525354555856575861596061626364656669676869707172737674757679777879828081828384858886878889908 行未改动总剩余牌数:$total \gets 9 \times K - 8$($9$ 种牌各 $K$ 张,已发 $8$ 张明牌)。
我们设情况数为 $ways$。
- 如果高桥和青木的暗牌数字相同: - $ways \gets$ 剩余该数字牌数 $ \times $ 剩余该数字牌数 $-1$。- 如果暗牌数字不同: - $ways \gets$ 剩余高桥暗牌数字牌数 $ \times $ 剩余青木暗牌数字牌数$。- 如果高桥和青木的暗牌数字相同:$ways \gets$ 剩余该数字牌数 $ \times $ 剩余该数字牌数 $-1$。- 如果暗牌数字不同:$ways \gets$ 剩余高桥暗牌数字牌数 $ \times $ 剩余青木暗牌数字牌数。
如此,$ans \gets \frac{ways}{total × (total-1)}$。如此,统计 $ans$ 为 $\frac{ways}{total\times(total-1)}$。
### 代码公开计划
```cpp24 行未改动
signed main() { ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
cin>>k>>s>>t;
for(int i=0;i<4;i++){ cnt[s[i]-'0']++; cnt[t[i]-'0']++; }
double ans=0; int tot=9*k-8;
for(int i=1;i<=9;i++){ for(int j=1;j<=9;j++){ if(i==j){ if(cnt[i]+2>k) continue; }else{ if(cnt[i]+1>k||cnt[j]+1>k) continue; }
int ways; if(i==j){ ways=(k-cnt[i])*(k-cnt[i]-1); }else{ ways=(k-cnt[i])*(k-cnt[j]); }
string s1=s.substr(0,4); string t1=t.substr(0,4);
int sc1=calc(s1,i); int sc2=calc(t1,j);
if(sc1>sc2){ ans+=(double)ways/(tot*(tot-1)); } } }
cout<<fixed<<setprecision(15)<<ans<<'\n'; IXcape;}```