{"id":64,"date":"2016-09-17T20:49:26","date_gmt":"2016-09-17T12:49:26","guid":{"rendered":"http:\/\/tyswly.com\/?p=64"},"modified":"2016-09-17T20:49:26","modified_gmt":"2016-09-17T12:49:26","slug":"noip2015%e5%ad%97%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/tys.fun\/?p=64","title":{"rendered":"[NOIP2015]\u5b57\u4e32"},"content":{"rendered":"<p>\u8fd9\u9053\u9898\uff0c\u5f53\u65f6\u76f4\u63a5\u628a\u6211\u6574\u61f5\u903c\u4e86\uff0c\u7ed3\u679c\u8fd9\u4e24\u5929\u770b\u4e86\u770b\uff0c\u987a\u5e26\u641c\u4e86\u4e0b\u9898\u89e3\uff0c\u53d1\u73b0\u5c45\u7136\u662f\u4e00\u9053DP\u3002\u3002\u6211\u7684DP\u662f\u5760\u5f31\u7684\u554a\u3002\u3002\u53c2\u8003\u9898\u89e3\uff0c\u7ec8\u4e8e\u641e\u51fa\u6765\u4e86\u8f6c\u79fb\u65b9\u7a0b\u3002<br \/>\n\u539a\u989c\u65e0\u803b\u5730\u628a\u4ee3\u7801\u53d1\u51fa\u6765<del>\uff08\u6838\u5fc3\u4ee3\u7801\u57fa\u672c\u7b97\u662f\u6284\u7684\u3002\u3002\uff09<\/del>\u3002<\/p>\n<pre class=\"lang:c++ decode:true \">#include &lt;iostream&gt;\n#include &lt;cstring&gt;\n#include &lt;cstdio&gt;\n#include &lt;algorithm&gt;\nconst int MOD = 1000000007;\nusing namespace std;\nchar a[1005], b[205];\nint n, m, k;\nint f[2][205][205], s[2][205][205];\nint main() {\n\tfreopen(\"2015substring.in\", \"r\", stdin);\n\tfreopen(\"2015substring.out\", \"w\", stdout);\n\tscanf(\"%d%d%d\", &amp;n, &amp;m, &amp;k);\n\tscanf(\"%s%s\", a + 1, b + 1);\n\tint now = 1, last = 0;\n\ts[0][0][0] = 1;\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\ts[now][0][0] = 1;\n\t\tfor (int j = 1; j &lt;= m; j++) {\n\t\t\tfor (int kk = 1; kk &lt;= k; kk++) {\n\t\t\t\tif (a[i] == b[j]) {\n\t\t\t\t\tf[now][j][kk] = (f[last][j - 1][kk] + s[last][j - 1][kk -1]) % MOD;\n\t\t\t\t} else {\n\t\t\t\t\tf[now][j][kk] = 0;\n\t\t\t\t}\n\t\t\t\ts[now][j][kk] = (s[last][j][kk] + f[now][j][kk]) % MOD;\n\t\t\t}\n\t\t}\n\t\tswap(now, last);\n\t}\n\tprintf(\"%d\\n\", s[last][m][k]);\n\treturn 0;\n}\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u9053\u9898\uff0c\u5f53\u65f6\u76f4\u63a5\u628a\u6211\u6574\u61f5\u903c\u4e86\uff0c\u7ed3\u679c\u8fd9\u4e24\u5929\u770b\u4e86\u770b\uff0c\u987a\u5e26\u641c\u4e86\u4e0b\u9898\u89e3\uff0c\u53d1\u73b0\u5c45\u7136\u662f\u4e00\u9053DP\u3002\u3002\u6211\u7684DP\u662f\u5760\u5f31\u7684\u554a\u3002\u3002\u53c2 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-report"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":0,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}