C++ Solution, use queue
\nclass Solution {\npublic:\n    double new21Game(int N, int K, int W) {\n        if(K == 0 || W == 1) return 1.0;\n        double res = 0;\n        double sum 
```\nclass Solution {\npublic:\n    double new21Game(int N, int K, int W) {\n        if(K == 0 || W == 1) return 1.0;\n        double res = 0;\n        double sum = 1.0;\n        queue<double> q;\n        for(int i = 1; i < W; i++) q.push(0);\n        q.push(1.0);\n        for(int i = 1; i < K; i++) {\n            q.push(sum / W);\n            sum += sum / W;\n            if(q.size() > W) {\n                sum -= q.front();\n                q.pop();\n            }\n        }\n        for(int i = K; i <= N && q.size(); i++) {\n            res += sum / W;\n            sum -= q.front();\n            q.pop();\n        }\n        return res;\n    }\n};\n```
[]