fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. const int N = 27;
  4.  
  5. int main() {
  6. // your code goes here
  7. long double f[N][N];
  8. for(int i=0; i<N; i++) {
  9. f[i][0] = f[0][i] = 1; // you will always win if you know one type of card has been depleted
  10. }
  11. for(int i=1; i<N; i++) {
  12. for(int j=1; j<N; j++) {
  13. f[i][j] = (abs(i-j) + i*f[i-1][j] + j*f[i][j-1])/(long double)(i+j);
  14. }
  15. }
  16. cout << "Your expected winnings are: " << f[N-1][N-1] << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
Your expected winnings are: 7.1554