Skip to content

Instantly share code, notes, and snippets.

@balamark
Created November 12, 2017 02:05
Show Gist options
  • Save balamark/db69092be6bcc7b903f234727784e9dc to your computer and use it in GitHub Desktop.
Save balamark/db69092be6bcc7b903f234727784e9dc to your computer and use it in GitHub Desktop.
class PrimeSoccer {
public:
using LL = long long;
LL C(int n, int m){
LL ans = 1L;
for(int i=1;i<=m;++i)
ans *= n--;
for(int i=1;i<=m;++i)
ans /= i;
return ans;
}
double getProbability(int skillOfTeamA, int skillOfTeamB) {
vector<int> aWin = {2,3,5,7,11,13,17};
double reta = 0.0, retb = 0.0, pa = skillOfTeamA/100.0, pb = skillOfTeamB/100.0;
for(int d : aWin)
reta += pow(pa, d)*pow((1-pa),(18-d))*C(18, d);
for(int d : aWin)
retb += pow(pb, d)*pow((1-pb),(18-d))*C(18, d);
return reta+retb-(reta*retb);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment