fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, const char * argv[])
  10. {
  11. int total = 0, bad = 0;
  12. string s = "0123456789";
  13. do {
  14. if (s[0] < '3' || s[1] < '3' || s[2] < '3' || s[3] < '3') bad++;
  15. total++;
  16. } while(next_permutation(s.begin(),s.end()));
  17. cout << double(bad)/total << endl;
  18. }
  19.  
Success #stdin #stdout 0.02s 4400KB
stdin
Standard input is empty
stdout
0.833333