{"id":131,"date":"2010-02-25T15:53:00","date_gmt":"2010-02-25T07:53:00","guid":{"rendered":"http:\/\/localhost\/?p=131"},"modified":"2010-02-25T15:53:00","modified_gmt":"2010-02-25T07:53:00","slug":"sgu_489","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=131","title":{"rendered":"SGU 489"},"content":{"rendered":"\n<p>\u5c31\u662f\u8bf4\u4e00\u4e2a1\u5230n\u7684\u6392\u5217\u5982\u679c\u662f\u4e00\u4e0a\u4e00\u4e0b\u7684\u3002\u3002\u90a3\u4e48\u5c31\u53eblocal extreme\u3002\u3002<\/p>\n<p>\u7136\u540e\u544a\u8bc9\u4f60n\u8ba9\u4f60\u6c421\u5230n\u7684\u6392\u5217\u91cclocal extream\u7684\u6570\u91cf\u3002\u3002<\/p>\n<p>\u6211\u592a\u65e0\u803b\u4e86\u3002\u3002\u9996\u5148\u66b4\u529b\u641c\u51fa1\u52308\u7684\u7ed3\u679c\u3002\u3002<\/p>\n<p>1,2,4,10,32,122,544,2770<\/p>\n<p>\u7136\u540e\u4e0a<a target=\"_blank\" href=\"http:\/\/www.research.att.com\/~njas\/sequences\/index.html?q=1%2C2%2C4%2C10%2C32%2C122%2C544%2C2770&amp;go=Search\">www.research.att.com\/~njas\/sequences\/index.html<\/a><\/p>\n<p>\u641c\u7d22\u8fd9\u4e2a\u6570\u5217\u3002\u3002\u7136\u540e\u627e\u5230\u4e86\u8fd9\u4e2a\u6570\u5217\u7684\u4ecb\u7ecd<a target=\"_blank\" href=\"http:\/\/mathworld.wolfram.com\/AlternatingPermutation.html\">mathworld.wolfram.com\/AlternatingPermutation.html<\/a><\/p>\n<p>\u7136\u540e\u7528<a href=\"http:\/\/mathworld.wolfram.com\/EulerZigzagNumber.html\">http:\/\/mathworld.wolfram.com\/EulerZigzagNumber.html<\/a>\u4e0a\u9762\u7684\u529e\u6cd5\u6765\u505a\u7684\u3002\u3002<\/p>\n<p>\u8bf4\u5b9e\u8bdd\u6211\u6839\u672c\u6ca1\u6709\u641e\u61c2\u8fd9\u4e2a\u662f\u4ec0\u4e48\u610f\u601d\uff01\u4f46\u662f\u6211\u8fd8\u662f\u5199\u4e86\u7a0b\u5e8f\u3002\u3002A\u6389\u4e86\u8fd9\u9053\u9898\u3002\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><\/p>\n<p>\u4ee5\u540e\u9047\u5230\u6570\u5217\u9898\u5c31\u8fd9\u4e48\u5e72\u4e86\u3002\u3002\u8bdd\u8bf4\u6211\u53d1\u73b0SGU\u4e0a\u8fc7\u4e86100\u9898\u4e86\u3002\u3002\u9ad8\u5174\u4e00\u4e0b<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0015.gif\" \/><\/p>\n<p>Code\uff1a<\/p>\n<p>#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxn=10000+10;int dp[2][maxn]={0};int main(){    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);    int n,m;cin&gt;&gt;n&gt;&gt;m;&#8211;n;if(!n){cout&lt;&lt;1%m&lt;&lt;endl;return 0;}    int now=0,old=1;    dp[now][1]=1;    for(int i=2;i&lt;=n;i++)    {        swap(now,old);        dp[now][0]=0;        for(int j=1;j&lt;=n;j++)        {            dp[now][j]=dp[now][j-1];            if(i&gt;j)            {                dp[now][j]+=dp[old][i-j];                if(dp[now][j]&gt;=m)                    dp[now][j]-=m;            }        }    }    int ans=0;    for(int i=1;i&lt;=n;i++)        ans+=dp[now][i],ans%=m;    cout&lt;&lt;(ans*2)%m&lt;&lt;endl;}<\/p>\n<p>\u672c\u9ad8\u4eae\u4ee3\u7801\u4f7f\u7528codeHl\u751f\u6210\uff0c<a target=\"_blank\" href=\"http:\/\/hi.baidu.com\/onlys_c\/blog\/item\/ef1149948c22d715d31b707e.html\">\u67e5\u770b\u8be6\u60c5<\/a><\/p>\n<p>PS\u3002\u3002\u6211\u603b\u7b97\u641e\u660e\u767d\u8fd9\u4e2a\u516c\u5f0f\u4e86<\/p>\n<p><img decoding=\"async\" class=\"blogimg\" small=\"0\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/d64223b52b0653c030add1f8.jpg\" \/><br \/>E(n,k)\u662f1\u5230n\u7684\u6392\u5217\u4e2d\u7b2c\u4e00\u4e2a\u662fk\u4e14\u4e00\u5f00\u59cb\u4e0b\u964d\u7684\u6570\u91cf\u3002\u3002<br \/>\u7531\u4e8e\u662f\u4e0b\u964d\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u8981\u5c0f\u4e8ek\u3002\u3002<br \/>\u90a3\u4e48\u5982\u679c\u4e0b\u4e00\u4e2a\u662fk-1\u7684\u8bdd\u3002\u3002<br \/>\u90a3\u4e48\u5c31\u662f\u5269\u4e0b\u7684\u6570\u5217\u7b2c\u4e00\u4e2a\u662fk-1\u5e76\u4e14\u4e0a\u5347\u7684\u65b9\u6cd5\u6570\u4e86\u3002\u3002<br \/>\u7531\u4e8ek\u5df2\u7ecf\u9009\u4e86\u3002\u3002\u90a3\u4e48k-1\u5728\u8fd9\u4e2a\u6570\u5217\u4e2d\u662f\u5012\u6570\u7b2cn-k\u4e2a\u3002\u3002<br \/>\u4e0a\u5347\u8ddf\u4e0b\u964d\u662f11\u5bf9\u5e94\u7684\u3002\u3002\u4e8e\u662f\u8fd9\u65b9\u9762\u7684\u662fE\uff08n-1\uff0cn-k\uff09\u3002\u3002<br \/>\u7136\u540e\u5982\u679c\u4e0b\u4e00\u4e2a\u4e0d\u662fk\u3002\u3002\u90a3\u4e48\u5c31\u662fE\uff08n\uff0ck-1\uff09\u4e86\u3002\u3002<br \/>\u52a0\u8d77\u6765\u5c31\u662f\u4e0a\u9762\u7684\u516c\u5f0f<br \/>\u8fd9\u4e2a\u91cc\u9762\u7b2c\u4e00\u4e2a\u662f\u4e0b\u964d\u3002\u3002\u6700\u540e\u7b54\u6848\u4e58\u4ee52\u3002\u3002\u3002\u3002<br \/>\u56e0\u6b64\u8981\u7279\u5224n=1\u7684\u60c5\u51b5\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c31\u662f\u8bf4\u4e00\u4e2a1\u5230n\u7684\u6392\u5217\u5982\u679c\u662f\u4e00\u4e0a\u4e00\u4e0b\u7684\u3002\u3002\u90a3\u4e48\u5c31\u53eblocal extreme\u3002\u3002 \u7136\u540e\u544a\u8bc9\u4f60n\u8ba9\u4f60\u6c421\u5230n\u7684\u6392\u5217\u91cclocal extream\u7684\u6570\u91cf\u3002\u3002 \u6211\u592a\u65e0\u803b\u4e86\u3002\u3002\u9996\u5148\u66b4\u529b\u641c\u51fa1\u52308\u7684\u7ed3\u679c\u3002\u3002 1,2,4,10,32,122,544,2770 \u7136\u540e\u4e0awww.research.att.com\/~njas\/sequences\/index.html \u641c\u7d22\u8fd9\u4e2a\u6570\u5217\u3002\u3002\u7136\u540e\u627e\u5230\u4e86\u8fd9\u4e2a\u6570\u5217\u7684\u4ecb\u7ecdmathworld.wolfram.com\/AlternatingPermutation.html \u7136\u540e\u7528http:\/\/mathworld.wolfram.com\/EulerZigzagNumber.html\u4e0a\u9762\u7684\u529e\u6cd5\u6765\u505a\u7684\u3002\u3002 \u8bf4\u5b9e\u8bdd\u6211\u6839\u672c\u6ca1\u6709\u641e\u61c2\u8fd9\u4e2a\u662f\u4ec0\u4e48\u610f\u601d\uff01\u4f46\u662f\u6211\u8fd8\u662f\u5199\u4e86\u7a0b\u5e8f\u3002\u3002A\u6389\u4e86\u8fd9\u9053\u9898\u3002\u3002 \u4ee5\u540e\u9047\u5230\u6570\u5217\u9898\u5c31\u8fd9\u4e48\u5e72\u4e86\u3002\u3002\u8bdd\u8bf4\u6211\u53d1\u73b0SGU\u4e0a\u8fc7\u4e86100\u9898\u4e86\u3002\u3002\u9ad8\u5174\u4e00\u4e0b Code\uff1a #include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxn=10000+10;int dp[2][maxn]={0};int main(){ \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin); int n,m;cin&gt;&gt;n&gt;&gt;m;&#8211;n;if(!n){cout&lt;&lt;1%m&lt;&lt;endl;return 0;} int now=0,old=1; dp[now][1]=1; for(int i=2;i&lt;=n;i++) { swap(now,old); dp[now][0]=0; for(int j=1;j&lt;=n;j++) { dp[now][j]=dp[now][j-1]; if(i&gt;j) { dp[now][j]+=dp[old][i-j]; if(dp[now][j]&gt;=m) dp[now][j]-=m; } } } int ans=0; for(int i=1;i&lt;=n;i++) ans+=dp[now][i],ans%=m; cout&lt;&lt;(ans*2)%m&lt;&lt;endl;} \u672c\u9ad8\u4eae\u4ee3\u7801\u4f7f\u7528codeHl\u751f\u6210\uff0c\u67e5\u770b\u8be6\u60c5 PS\u3002\u3002\u6211\u603b\u7b97\u641e\u660e\u767d\u8fd9\u4e2a\u516c\u5f0f\u4e86 E(n,k)\u662f1\u5230n\u7684\u6392\u5217\u4e2d\u7b2c\u4e00\u4e2a\u662fk\u4e14\u4e00\u5f00\u59cb\u4e0b\u964d\u7684\u6570\u91cf\u3002\u3002\u7531\u4e8e\u662f\u4e0b\u964d\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u8981\u5c0f\u4e8ek\u3002\u3002\u90a3\u4e48\u5982\u679c\u4e0b\u4e00\u4e2a\u662fk-1\u7684\u8bdd\u3002\u3002\u90a3\u4e48\u5c31\u662f\u5269\u4e0b\u7684\u6570\u5217\u7b2c\u4e00\u4e2a\u662fk-1\u5e76\u4e14\u4e0a\u5347\u7684\u65b9\u6cd5\u6570\u4e86\u3002\u3002\u7531\u4e8ek\u5df2\u7ecf\u9009\u4e86\u3002\u3002\u90a3\u4e48k-1\u5728\u8fd9\u4e2a\u6570\u5217\u4e2d\u662f\u5012\u6570\u7b2cn-k\u4e2a\u3002\u3002\u4e0a\u5347\u8ddf\u4e0b\u964d\u662f11\u5bf9\u5e94\u7684\u3002\u3002\u4e8e\u662f\u8fd9\u65b9\u9762\u7684\u662fE\uff08n-1\uff0cn-k\uff09\u3002\u3002\u7136\u540e\u5982\u679c\u4e0b\u4e00\u4e2a\u4e0d\u662fk\u3002\u3002\u90a3\u4e48\u5c31\u662fE\uff08n\uff0ck-1\uff09\u4e86\u3002\u3002\u52a0\u8d77\u6765\u5c31\u662f\u4e0a\u9762\u7684\u516c\u5f0f\u8fd9\u4e2a\u91cc\u9762\u7b2c\u4e00\u4e2a\u662f\u4e0b\u964d\u3002\u3002\u6700\u540e\u7b54\u6848\u4e58\u4ee52\u3002\u3002\u3002\u3002\u56e0\u6b64\u8981\u7279\u5224n=1\u7684\u60c5\u51b5\u3002\u3002<\/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\/131"}],"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=131"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}