{"id":178,"date":"2010-03-22T12:37:00","date_gmt":"2010-03-22T04:37:00","guid":{"rendered":"http:\/\/localhost\/?p=178"},"modified":"2010-03-22T12:37:00","modified_gmt":"2010-03-22T04:37:00","slug":"scoi2009_games","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=178","title":{"rendered":"[SCOI2009]\u6e38\u620f"},"content":{"rendered":"\n<p>[SCOI2009]\u6e38\u620f <\/p>\n<p>Time Limit:1000MS  Memory Limit:165536K<br \/>Total Submit:15 Accepted:11<\/p>\n<p><strong>Description <\/strong><\/p>\n<p>windy\u5b66\u4f1a\u4e86\u4e00\u79cd\u6e38\u620f\u3002 <br \/>\u5bf9\u4e8e1\u5230N\u8fd9N\u4e2a\u6570\u5b57\uff0c\u90fd\u6709\u552f\u4e00\u4e14\u4e0d\u540c\u76841\u5230N\u7684\u6570\u5b57\u4e0e\u4e4b\u5bf9\u5e94\u3002 <br \/>\u6700\u5f00\u59cbwindy\u628a\u6570\u5b57\u6309\u987a\u5e8f1\uff0c2\uff0c3\uff0c\u2026\u2026\uff0cN\u5199\u4e00\u6392\u5728\u7eb8\u4e0a\u3002 <br \/>\u7136\u540e\u518d\u5728\u8fd9\u4e00\u6392\u4e0b\u9762\u5199\u4e0a\u5b83\u4eec\u5bf9\u5e94\u7684\u6570\u5b57\u3002 <br \/>\u7136\u540e\u53c8\u5728\u65b0\u7684\u4e00\u6392\u4e0b\u9762\u5199\u4e0a\u5b83\u4eec\u5bf9\u5e94\u7684\u6570\u5b57\u3002 <br \/>\u5982\u6b64\u53cd\u590d\uff0c\u76f4\u5230\u5e8f\u5217\u518d\u6b21\u53d8\u4e3a1\uff0c2\uff0c3\uff0c\u2026\u2026\uff0cN\u3002 <\/p>\n<p>\u5982\uff1a <br \/>1 2 3 4 5 6 <br \/>\u5bf9\u5e94\u7684\u5173\u7cfb\u4e3a <br \/>1-&gt;2 2-&gt;3 3-&gt;1 4-&gt;5 5-&gt;4 6-&gt;6 <br \/>windy\u7684\u64cd\u4f5c\u5982\u4e0b <\/p>\n<p>1 2 3 4 5 6 <br \/>2 3 1 5 4 6 <br \/>3 1 2 4 5 6 <br \/>1 2 3 5 4 6 <br \/>2 3 1 4 5 6 <br \/>3 1 2 5 4 6 <br \/>1 2 3 4 5 6 <\/p>\n<p>\u8fd9\u65f6\uff0c\u6211\u4eec\u5c31\u6709\u82e5\u5e72\u63921\u5230N\u7684\u6392\u5217\uff0c\u4e0a\u4f8b\u4e2d\u67097\u6392\u3002 <br \/>\u73b0\u5728windy\u60f3\u77e5\u9053\uff0c\u5bf9\u4e8e\u6240\u6709\u53ef\u80fd\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u6709\u591a\u5c11\u79cd\u53ef\u80fd\u7684\u6392\u6570\u3002 <\/p>\n<p><strong>Input <\/strong><\/p>\n<p>\u5305\u542b\u4e00\u4e2a\u6574\u6570\uff0cN\u3002 <\/p>\n<p><strong>Output <\/strong><\/p>\n<p>\u5305\u542b\u4e00\u4e2a\u6574\u6570\uff0c\u53ef\u80fd\u7684\u6392\u6570\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<\/p>\n<p><strong>Source <\/strong><\/p>\n<p>Day1<br \/>\u8fd9\u9053\u9898\u76ee\u5f88\u660e\u663e\u5c31\u662f\u7ed9\u4f60\u4e00\u4e2aN\uff0c\u7136\u540e\u6c42\u5728\u548c\u7684N\u7684\u6570\u5217\u4e2d\uff0c\u6700\u5c0f\u516c\u500d\u6570\u6709\u51e0\u79cd\u53ef\u80fd\u7684\u60c5\u51b5\u3002<br \/>\u5f88\u660e\u663e\u5982\u679c\u4e00\u4e2a\u6570A=p1^a1*p2^a2*&#8230;.\u7684\u8bdd\uff0c\u4ed6\u80fd\u88ab\u8868\u8fbe\u51fa\u6765\u7684\u5145\u5206\u5fc5\u8981\u6761\u4ef6\u662f\uff1a<br \/>p1^a1+p2^a2+&#8230;..&lt;=N\u8fd9\u662f\u5f88\u597d\u8bc1\u660e\u7684\uff0c\u5c31\u4e0d\u8bf4\u4e86\u3002\u90a3\u4e48\u5f88\u663e\u7136\u5c31\u53d8\u6210\u4e00\u4e2aDP\u7684\u95ee\u9898\u4e86\u3002<br \/>\u8bbeF(i,j)\u4e3a\u7b2ci\u4e2a\u7d20\u6570\u5f00\u59cb\u548c\u5c0f\u4e8ej\u6709\u591a\u5c11\u60c5\u51b5\uff0c\u5177\u4f53\u770b\u4ee3\u7801\u628a(*^__^*) \u3002\u3002\u8fd9\u53ef\u4ee5\u8bf4\u662f\u4e00\u9053\u6570\u5b66\u95ee\u9898\u4e86\u3002\u3002\u770b\u6765\u6570\u5b66\u5b66\u591a\u4e86\u4e5f\u662f\u6709\u597d\u5904\u7684\u56e7\u3002\u3002<br \/>Code\uff1a<\/p>\n<p>#include&lt;iostream&gt;using namespace std;const int maxn=1000+100;bool IsPrime(int p){    if(p==2) return true;    if(p%2==0) return false;    for(int x=3;x*x&lt;=p;x+=2)        if(p%x==0) return false;    return true;}int Ps[maxn],cnt=0,n;void GetPrime() \/\/\u76f4\u63a5\u5199\u66b4\u529b\u4e86\uff0c\u61d2\u5f97\u5199\u7b5b\u6cd5\u4e86\u3002\u3002{    for(int x=2;x&lt;=n;x++)        if(IsPrime(x))            Ps[cnt++]=x;}typedef long long ll;ll F[maxn][maxn];bool s[maxn][maxn]={0};ll dfs(int pos,int N) \/\/\u8bb0\u5fc6\u5316\u641c\u7d22 pos-cnt\u7684\u7d20\u6570\uff0c\u548c\u5c0f\u4e8eN\u6709\u591a\u5c11\u79cd\u60c5\u51b5{    if(pos==cnt&amp;&amp;N&gt;=0) return 1; \/\/\u8fb9\u754c\u60c5\u51b5    ll&amp;ans=F[pos][N]; \/\/\u7528\u5f15\u7528\u6bd4\u8f83\u65b9\u4fbf    if(s[pos][N]) return ans;     ans=0;s[pos][N]=true;    for(int x=Ps[pos];x&lt;=N;x*=Ps[pos]) \/\/\u679a\u4e3e\u7b2cpos\u4e2a\u7d20\u6570\u7684\u5e42\u6570    {        ans+=dfs(pos+1,N-x);    }    ans+=dfs(pos+1,N); \/\/\u5982\u679c\u4e0d\u9009\u8fd9\u4e2a\u7d20\u6570\u7684\u8bdd    return ans;}int main(){    cin&gt;&gt;n;GetPrime();    cout&lt;&lt;dfs(0,n)&lt;&lt;endl;}\u3010\u8f93\u51fa\u6837\u4f8b\u4e00\u30113\u3010\u8f93\u51fa\u6837\u4f8b\u4e8c\u301116\u3010\u6570\u636e\u89c4\u6a21\u548c\u7ea6\u5b9a\u301130%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= N &lt;= 10 \u3002100%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= N &lt;= 1000 \u3002\u3010\u8f93\u5165\u6837\u4f8b\u4e00\u30113\u3010\u8f93\u5165\u6837\u4f8b\u4e8c\u301110 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[SCOI2009]\u6e38\u620f Time Limit:1000MS Memory Limit:165536KTotal Submit:15 Accepted:11 Description windy\u5b66\u4f1a\u4e86\u4e00\u79cd\u6e38\u620f\u3002 \u5bf9\u4e8e1\u5230N\u8fd9N\u4e2a\u6570\u5b57\uff0c\u90fd\u6709\u552f\u4e00\u4e14\u4e0d\u540c\u76841\u5230N\u7684\u6570\u5b57\u4e0e\u4e4b\u5bf9\u5e94\u3002 \u6700\u5f00\u59cbwindy\u628a\u6570\u5b57\u6309\u987a\u5e8f1\uff0c2\uff0c3\uff0c\u2026\u2026\uff0cN\u5199\u4e00\u6392\u5728\u7eb8\u4e0a\u3002 \u7136\u540e\u518d\u5728\u8fd9\u4e00\u6392\u4e0b\u9762\u5199\u4e0a\u5b83\u4eec\u5bf9\u5e94\u7684\u6570\u5b57\u3002 \u7136\u540e\u53c8\u5728\u65b0\u7684\u4e00\u6392\u4e0b\u9762\u5199\u4e0a\u5b83\u4eec\u5bf9\u5e94\u7684\u6570\u5b57\u3002 \u5982\u6b64\u53cd\u590d\uff0c\u76f4\u5230\u5e8f\u5217\u518d\u6b21\u53d8\u4e3a1\uff0c2\uff0c3\uff0c\u2026\u2026\uff0cN\u3002 \u5982\uff1a 1 2 3 4 5 6 \u5bf9\u5e94\u7684\u5173\u7cfb\u4e3a 1-&gt;2 2-&gt;3 3-&gt;1 4-&gt;5 5-&gt;4 6-&gt;6 windy\u7684\u64cd\u4f5c\u5982\u4e0b 1 2 3 4 5 6 2 3 1 5 4 6 3 1 2 4 5 6 1 2 3 5 4 6 2 3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/178"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}