fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string winners[8] = {"France", "Germany", "Spain", "Germany", "Italy", "Germany", "Spain", "England"};
  11. string runnersup[8] = {"Portugal", "England", "Italy", "Spain1", "Ukraine", "Spain2", "Scotland", "Turkey"};
  12. sort(runnersup, runnersup+8);
  13. int count = 0;
  14. do {
  15. bool badseeding = false;
  16. for (int i = 0; i < 8; ++i)
  17. {
  18. if (winners[i].substr(0,3) == runnersup[i].substr(0,3))
  19. {
  20. badseeding = true;
  21. break;
  22. }
  23. }
  24. if (!badseeding) ++count;
  25. } while (next_permutation(runnersup, runnersup+8));
  26. cout << "different seedings: " << count << endl;
  27. cout << fixed << setprecision(5) << "probability: " << 1.0 / count << endl;
  28. }
Success #stdin #stdout 0.08s 2864KB
stdin
Standard input is empty
stdout
different seedings: 17088
probability: 0.00006