C++ straight forward solution
class Solution { public:     double new21Game(int N, int K, int W) {         if (K==0)             return 1;         vector<double> dp(K+W,0);         dp[0]=1.0
```
class Solution {
public:
    double new21Game(int N, int K, int W) {
        if (K==0)
            return 1;
        vector<double> dp(K+W,0);
        dp[0]=1.0;
        double S = 0;
        for (int i=1;i<K;++i) {
            if (i>=W+1)
                S=S-dp[i-W-1]+dp[i-1];
            else
                S=S+dp[i-1];
            dp[i]=1.0/W*S;
        }
        double p = 0.0;
        for (int i=K;i<K+W;++i) {
            if (i>=W+1)
                S-=dp[i-W-1];
            if (i-1<K)
                S+=dp[i-1];
            dp[i]=1.0/W*S;
            if (i<=N)
                p += dp[i];
        }
        return p;
    }
};
```
[]