#include <iostream>
using namespace std;
const int N = 27;
int main() {
// your code goes here
long double f[N][N];
for(int i=0; i<N; i++) {
f[i][0] = f[0][i] = 1; // you will always win if you know one type of card has been depleted
}
for(int i=1; i<N; i++) {
for(int j=1; j<N; j++) {
f[i][j] = (abs(i-j) + i*f[i-1][j] + j*f[i][j-1])/(long double)(i+j);
}
}
cout << "Your expected winnings are: " << f[N-1][N-1] << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDI3OwoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglsb25nIGRvdWJsZSBmW05dW05dOwoJZm9yKGludCBpPTA7IGk8TjsgaSsrKSB7CgkJZltpXVswXSA9IGZbMF1baV0gPSAxOyAvLyB5b3Ugd2lsbCBhbHdheXMgd2luIGlmIHlvdSBrbm93IG9uZSB0eXBlIG9mIGNhcmQgaGFzIGJlZW4gZGVwbGV0ZWQKCX0KCWZvcihpbnQgaT0xOyBpPE47IGkrKykgewoJCWZvcihpbnQgaj0xOyBqPE47IGorKykgewoJCQlmW2ldW2pdID0gKGFicyhpLWopICsgaSpmW2ktMV1bal0gKyBqKmZbaV1bai0xXSkvKGxvbmcgZG91YmxlKShpK2opOwoJCX0KCX0KCWNvdXQgPDwgIllvdXIgZXhwZWN0ZWQgd2lubmluZ3MgYXJlOiAiIDw8IGZbTi0xXVtOLTFdIDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==