Skip to content

Instantly share code, notes, and snippets.

@balamark
Last active November 12, 2017 01:58
Show Gist options
  • Save balamark/062c0221c134d47da5da7b55197af7c5 to your computer and use it in GitHub Desktop.
Save balamark/062c0221c134d47da5da7b55197af7c5 to your computer and use it in GitHub Desktop.
incorrect solution
// was trying to sum up Pa + Pb_selective {2,3,17} but the probability that both team score a prime should
// be calculated this way pA * pB
double getProbability(int skillOfTeamA, int skillOfTeamB) {
vector<int> aWin = {2,3,5,7,11,13,17}, bWin = {2,3,17};
double ret, pa = skillOfTeamA/100.0, pb = skillOfTeamB/100.0;
for(int d : aWin)
ret += pow(pa, d)*pow(pb,(18-d))*C(18, d);
for(int d: bWin)
ret += pow(pb, d)*pow(pa,(18-d))*C(18, d);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment