{"id":278,"date":"2018-10-30T19:44:42","date_gmt":"2018-10-30T11:44:42","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=278"},"modified":"2018-10-30T19:44:42","modified_gmt":"2018-10-30T11:44:42","slug":"cf148d-bag-of-mice","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/30\/cf148d-bag-of-mice\/","title":{"rendered":"CF148D Bag of mice"},"content":{"rendered":"<p>\u770b\u5230\\(w,b \\le 1000\\)\uff0c\u6211\u4eec\u53ef\u4ee5\u5927\u80c6\u731c\u60f3\u590d\u6742\u5ea6\u662f\\(w*b\\)\u7684\uff08\u5927\u96fe\uff09<br \/>\n\u90a3\u4e48\u6211\u4eec\u8bbe\\(f[i][j]\\)\u8868\u793a\uff0c\u5305\u91cc\u8fd8\u5269\u4e0b\\(i\\)\u53ea\u767d\u8001\u9f20\uff0c\\(j\\)\u53ea\u9ed1\u8001\u9f20\u7684\u65f6\u5019\uff0c\u8f6e\u5230\u516c\u4e3b\u62bd\uff0c\u8d62\u7684\u671f\u671b\u3002<br \/>\n\u4ed4\u7ec6\u770b\u4e86\u770b\u9898\u610f\uff08\u4e4b\u524d\u9898\u610f\u770b\u9519\u4e86\uff0c\u778e\u60f3\u534a\u5929\uff0c\u6de6\u3002\uff09\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u516c\u4e3b\u8f93\u4f1a\u53d1\u751f\u5728\u4e24\u79cd\u60c5\u51b5\u4e0b\uff1a<br \/>\n\u4e00\uff1a\u5305\u91cc\u6ca1\u6709\u767d\u8001\u9f20\u4e86\uff1b\u4e8c\uff1a\u516c\u4e3b\u62bd\u5230\u4e86\u9ed1\u8001\u9f20\u800c\u9f99\u62bd\u5230\u4e86\u767d\u8001\u9f20\u3002<br \/>\n\u540c\u65f6\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u5c40\u9762\uff0c\u516c\u4e3b\u80dc\u5229\u7684\u6982\u7387\u6709\u4e24\u90e8\u5206\uff1b<br \/>\n\u4e00\uff1a\u516c\u4e3b\u62bd\u5230\u4e86\u767d\u7403\u3002\u4e8c\uff1a\u516c\u4e3b\u7684\u72b6\u6001\u8f6c\u79fb\u5230\u7684\u72b6\u6001\u62bd\u5230\u4e86\u767d\u7403\u3002<br \/>\n\u6211\u4eec\u5206\u7c7b\u8ba8\u8bba\u3002<br \/>\n\u9996\u5148\uff0c\u4f9d\u636e\u516c\u4e3b\u62bd\u5230\u767d\u7403\u7684\u6982\u7387\u662f\\(\\frac{i}{i+j}\\)\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff1a<br \/>\n$$f_{i,j}+=\\frac{i}{i+j}$$<br \/>\n\u7136\u540e\uff0c\u7528\u586b\u8868\u6cd5\uff0c\u6211\u4eec\u53d1\u73b0\uff0c\u516c\u4e3b\u62bd\u5230\u4e86\u9ed1\u8001\u9f20\u4e14\u9f99\u62bd\u5230\u9ed1\u8001\u9f20\u7684\u6982\u7387\u662f\uff1a<br \/>\n$$\\frac{j}{i+j}*\\frac{j-1}{i+j-1}$$<br \/>\n\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8dd1\u51fa\u4e00\u53ea\u767d\u8001\u9f20\u7684\u6982\u7387\u662f\uff1a<br \/>\n$$\\frac{j}{i+j}*\\frac{j-1}{i+j-1}*\\frac{i}{i+j-2}$$<br \/>\n\u8dd1\u51fa\u4e00\u53ea\u9ed1\u8001\u9f20\u7684\u6982\u7387\u662f\uff1a<br \/>\n$$\\frac{j}{i+j}*\\frac{j-1}{i+j-1}*\\frac{j-2}{i+j-2}$$<br \/>\n\u6240\u4ee5\u5f97\u5230\u8f6c\u79fb\u65b9\u7a0b\uff1a<br \/>\n$$f_{i,j}=\\frac{j}{i+j}*\\frac{j-1}{i+j-1}+f_{i-1,j-2}*\\frac{j}{i+j}*\\frac{j-1}{i+j-1}*\\frac{i}{i+j-2}+$$<br \/>\n$$f_{i,j-3}*\\frac{j}{i+j}*\\frac{j-1}{i+j-1}*\\frac{j-2}{i+j-2}$$<br \/>\n\u4e8e\u662f\u586b\u8868\u6cd5\u53ef\u5f97\u89e3\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\nusing namespace std;\r\nint w,b;\r\ndouble f[1005][1005];\r\nvoid init(){\r\n    scanf(\"%d%d\",&amp;w,&amp;b);\r\n    for(int i=1;i&lt;=w;++i){\r\n        for(int j=1;j&lt;=b;++j){\r\n            f[i][j]=0;\r\n        }\r\n    }\r\n    for(int i=1;i&lt;=w;++i){\r\n        f[i][0]=1;\r\n    }\r\n    for(int i=1;i&lt;=b;++i){\r\n        f[0][i]=0;\r\n    }\r\n    for(int i=1;i&lt;=w;++i){\r\n        for(int j=1;j&lt;=b;++j){\r\n            f[i][j]+=(double)i\/(i+j);\r\n            if(j&gt;=2){\r\n                f[i][j]+=f[i-1][j-2]*(double)j\/(i+j)*(j-1)\/(i+j-1)*i\/(i+j-2);\r\n            }\r\n            if(j&gt;=3){\r\n                f[i][j]+=f[i][j-3]*(double)j\/(i+j)*(j-1)\/(i+j-1)*(j-2)\/(i+j-2);\r\n            }\r\n        }\r\n    }\r\n    printf(\"%.9lf\",f[w][b]);\r\n}\r\nint main(){\r\n    init();\r\n    return 0;\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u5230\\(w,b \\le 1000\\)\uff0c\u6211\u4eec\u53ef\u4ee5\u5927\u80c6\u731c\u60f3\u590d\u6742\u5ea6\u662f\\(w*b\\)\u7684\uff08\u5927\u96fe\uff09 \u90a3\u4e48\u6211\u4eec\u8bbe\\(f[i] &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/30\/cf148d-bag-of-mice\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cCF148D Bag of mice\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,24,29,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/278"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=278"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":279,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/278\/revisions\/279"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}