fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <random>
  6. #include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main()
  12. {
  13. random_device rd;
  14. mt19937 g(rd());
  15. vector<int> v { 0,0,0,0,0,0,0,0,0,3,3,3,3,3,3,100,100,100};
  16. unsigned long long total = 0, ok = 0;
  17. for(; total < 10000000;)
  18. {
  19. shuffle(v.begin(),v.end(),g);
  20. total++;
  21. int sum = v[0]+v[1]+v[2]+v[3]+v[4]+v[5];
  22. if (sum == 106)
  23. {
  24. sum = v[6]+v[7]+v[8]+v[9]+v[10]+v[11];
  25. if (sum == 106)
  26. {
  27. ok++;
  28. }
  29. }
  30. }
  31. cout << double(ok)/total << "\n";
  32. }
  33.  
Success #stdin #stdout 3.03s 4516KB
stdin
Standard input is empty
stdout
0.0529088