版本比较
AT_abc193_d [ABC193D] Poker-题解
正文
增加 11 行删除 11 行
9 行未改动1011121314141516161718192024 行未改动454647484949505151525354555656575859596061626364656667676869707172737474757677777879808081828384858686878889909 行未改动
我们设情况数为 $ways$。
- 如果高桥和青木的暗牌数字相同:$ways \gets$ 剩余该数字牌数 $ \times $ 剩余该数字牌数 $-1$。- 如果暗牌数字不同:$ways \gets$ 剩余高桥暗牌数字牌数 $ \times $ 剩余青木暗牌数字牌数$。- 如果暗牌数字不同:$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;}```