{"id":267,"date":"2010-05-29T17:44:00","date_gmt":"2010-05-29T09:44:00","guid":{"rendered":"http:\/\/localhost\/?p=267"},"modified":"2023-01-30T20:00:43","modified_gmt":"2023-01-30T20:00:43","slug":"scoi2009_windy_number","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=267","title":{"rendered":"[SCOI2009]windy\u6570"},"content":{"rendered":"\n<p>[SCOI2009]windy\u6570 <\/p>\n<p>Time Limit:1000MS&#160; Memory Limit:165536K<br \/>Total Submit:118 Accepted:54<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> windy\u5b9a\u4e49\u4e86\u4e00\u79cdwindy\u6570\u3002 <br \/>\u4e0d\u542b\u524d\u5bfc\u96f6\u4e14\u76f8\u90bb\u4e24\u4e2a\u6570\u5b57\u4e4b\u5dee\u81f3\u5c11\u4e3a2\u7684\u6b63\u6574\u6570\u88ab\u79f0\u4e3awindy\u6570\u3002 <br \/>windy\u60f3\u77e5\u9053\uff0c\u5728A\u548cB\u4e4b\u95f4\uff0c\u5305\u62ecA\u548cB\uff0c\u603b\u5171\u6709\u591a\u5c11\u4e2awindy\u6570\uff1f <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u5305\u542b\u4e24\u4e2a\u6574\u6570\uff0cA B\u3002 <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u4e00\u4e2a\u6574\u6570\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>\u3010\u8f93\u5165\u6837\u4f8b\u4e00\u3011<br \/>1 10<\/p>\n<p>\u3010\u8f93\u5165\u6837\u4f8b\u4e8c\u3011<br \/>25 50<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>\u3010\u8f93\u51fa\u6837\u4f8b\u4e00\u3011<br \/>9<\/p>\n<p>\u3010\u8f93\u51fa\u6837\u4f8b\u4e8c\u3011<br \/>20<\/p>\n<p>\u3010\u6570\u636e\u89c4\u6a21\u548c\u7ea6\u5b9a\u3011<br \/>20%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= A &lt;= B &lt;= 1000000 \u3002<br \/>100%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= A &lt;= B &lt;= 2000000000 \u3002<\/p>\n<p><strong>Source <\/strong><\/p>\n<p> Day1<br \/>\u54ce\u3002\u3002\u8fd8\u662f\u6570\u4f4d\u7edf\u8ba1\u95ee\u9898\uff0c\u5e78\u597d\u5bf9\u4ed8\u8fd9\u79cd\u9898\u76ee\u53ef\u4ee5\u5199\u4e2a\u66b4\u529b\u7a0b\u5e8f\u6765\u5bf9\u62cd\uff0c\u4e0d\u7136\u80af\u5b9a\u8981\u60b2\u5267\u554a\u56e7\u3002\u3002\u3002\u6709\u7ecf\u9a8c\u4e86\u3002\u3002\u603b\u7ed3\u4e00\u4e0b\uff1a<br \/>\u9996\u5148\u8981\u6ce8\u610f\u7b2c\u4e00\u4f4d\u5c31\u662f0\u7684\u60c5\u51b5\uff0c\u7740\u5e76\u4e0d\u4ee3\u8868\u8fd9\u4f4d\u662f0\uff0c\u800c\u662f\u5ffd\u7565\u8fd9\u4f4d\uff0c\u6240\u4ee5\u6309\u7167\u516c\u5f0f\u5199\u4e2a\u7279\u6b8a\u7684\u7edf\u8ba1\u7684\u5c31OK\u4e86\u3002\u3002<br \/>\u8fd8\u6709\u5c31\u662f\u53ef\u4ee5\u524d\u9762\u7684\u6570\u4f4d\u5df2\u7ecf\u4e0d\u80fd\u662fwindy\u6570\u4e86\uff0c\u5c31\u4e0d\u8981\u63a8\u4e0b\u53bb\u4e86\u3002\u3002<br \/>\u540c\u65f6\u4e00\u5b9a\u8981\u5199\u4e2a\u66b4\u529b\u5bf9\u62cd\u3002\u3002<br \/>\u5bf9\u62cd\u8981\u591a\u8003\u8651\u8fd9\u6837\u7684\u6570\u636e\uff1a<br \/>1\uff1a 1-1000000\u8fd9\u6837\u7684.\u3002\u3002<br \/>2\uff1a1-99999\u8fd9\u6837\u7684\u3002\u3002<br \/>3: xxx-xxxxx\u8fd9\u6837\u7684\uff0c\u81f3\u5c11\u5dee2\u4f4d\u3002\u3002<br \/>4\uff1a\u5982\u679c\u8fd8\u4e0d\u653e\u5fc3\u968f\u673a\u4e2aN\u7ec4\u6765\u641e\u641e\u3002\u3002<br \/>5\uff1a\u6700\u597d\u7528long long\u514d\u5f97\u6ea2\u51fa\u3002\u3002<br \/>6\uff1a\u6ca1\u6709\u4e86\u3002\u3002<\/p>\n<p>\u5bf9\u62cd\u5668\uff1a<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;vector&gt;\r\n#include &lt;algorithm&gt;\r\n#include &lt;utility&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;cstdio&gt;\r\n#include &lt;cmath&gt;\r\n#include &lt;cstdlib&gt;\r\n#include &lt;sstream&gt;\r\n#define rep(i,n) for(int i=0;i&lt;n;i++)\r\n#define pb push_back\r\nconst int inf=~0U&gt;&gt;1;\r\nusing namespace std;\r\ntypedef ostringstream OSS;\r\nint C[10];\r\nbool Check(int a)\r\n{\r\n    OSS t;\r\n    t&lt;&lt;a;\r\n    string s=t.str();\r\n    rep(i,s.size()-1)if(abs(s[i]-s[i+1])&lt;2)return false;\r\n    return true;\r\n}\r\nint main()\r\n{\r\n    int a,b,c=0;\r\n    cin&gt;&gt;a&gt;&gt;b;\r\n    for(int i=a; i&lt;=b; i++)c+=Check(i);\r\n    cout&lt;&lt;c&lt;&lt;endl;\r\n}\r\n<\/pre>\n<p>\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;vector&gt;\r\n#include &lt;algorithm&gt;\r\n#include &lt;utility&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;cstdio&gt;\r\n#include &lt;cmath&gt;\r\n#include &lt;cstdlib&gt;\r\n#define rep(i,n) for(int i=0;i&lt;n;i++)\r\n#define pb push_back\r\nconst int inf=~0U&gt;&gt;1,maxd=12;\r\nusing namespace std;\r\ntypedef long long ll;\r\nll Count[maxd][10]= {},C;\r\nint N[maxd],n;\r\nvoid PreDo()\r\n{\r\n    rep(j,10)Count[1][j]=1;\r\n    for(int i=2; i&lt;maxd; i++)\r\n    {\r\n        rep(j,10)\r\n        {\r\n            Count[i][j]=0;\r\n            rep(k,10)if(abs(k-j)&gt;=2)Count[i][j]+=Count[i-1][k];\r\n        }\r\n    }\r\n}\r\nvoid Dfs(int p,int l)\r\n{\r\n    int t=N[p];\r\n    if(p==0)\r\n    {\r\n        rep(j,t+1)if(abs(j-l)&gt;=2)C++;\r\n        return;\r\n    }\r\n    rep(i,t)\r\n    {\r\n        if(abs(i-l)&gt;=2)\r\n        {\r\n            if(p==n-1&amp;&amp;i==0)\r\n            {\r\n                rep(j,p)rep(k,9)C+=Count[j+1][k+1];\r\n            }\r\n            else\r\n            {\r\n                C+=Count[p+1][i];\r\n            }\r\n        }\r\n    }\r\n    if(abs(t-l)&gt;=2)Dfs(p-1,t);\r\n}\r\nll Cal(ll A)\r\n{\r\n    if(!A)return 0;\r\n    for(n=0; A; A\/=10,n++)N[n]=A%10;\r\n    C=0;\r\n    Dfs(n-1,20);\r\n    return C;\r\n}\r\nint main()\r\n{\r\n\/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);\r\n    PreDo();\r\n    ll a,b;\r\n    cin&gt;&gt;a&gt;&gt;b;\r\n    cout&lt;&lt;Cal(b)-Cal(a-1)&lt;&lt;endl;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>[SCOI2009]windy\u6570 Time Limit:1000MS&#160; Memory Limit:165536KTotal Submit:118 Accepted:54 Description windy\u5b9a\u4e49\u4e86\u4e00\u79cdwindy\u6570\u3002 \u4e0d\u542b\u524d\u5bfc\u96f6\u4e14\u76f8\u90bb\u4e24\u4e2a\u6570\u5b57\u4e4b\u5dee\u81f3\u5c11\u4e3a2\u7684\u6b63\u6574\u6570\u88ab\u79f0\u4e3awindy\u6570\u3002 windy\u60f3\u77e5\u9053\uff0c\u5728A\u548cB\u4e4b\u95f4\uff0c\u5305\u62ecA\u548cB\uff0c\u603b\u5171\u6709\u591a\u5c11\u4e2awindy\u6570\uff1f Input \u5305\u542b\u4e24\u4e2a\u6574\u6570\uff0cA B\u3002 Output \u4e00\u4e2a\u6574\u6570\u3002 Sample Input \u3010\u8f93\u5165\u6837\u4f8b\u4e00\u30111 10 \u3010\u8f93\u5165\u6837\u4f8b\u4e8c\u301125 50 Sample Output \u3010\u8f93\u51fa\u6837\u4f8b\u4e00\u30119 \u3010\u8f93\u51fa\u6837\u4f8b\u4e8c\u301120 \u3010\u6570\u636e\u89c4\u6a21\u548c\u7ea6\u5b9a\u301120%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= A &lt;= B &lt;= 1000000 \u3002100%\u7684\u6570\u636e\uff0c\u6ee1\u8db3 1 &lt;= A &lt;= B &lt;= 2000000000 \u3002 Source Day1\u54ce\u3002\u3002\u8fd8\u662f\u6570\u4f4d\u7edf\u8ba1\u95ee\u9898\uff0c\u5e78\u597d\u5bf9\u4ed8\u8fd9\u79cd\u9898\u76ee\u53ef\u4ee5\u5199\u4e2a\u66b4\u529b\u7a0b\u5e8f\u6765\u5bf9\u62cd\uff0c\u4e0d\u7136\u80af\u5b9a\u8981\u60b2\u5267\u554a\u56e7\u3002\u3002\u3002\u6709\u7ecf\u9a8c\u4e86\u3002\u3002\u603b\u7ed3\u4e00\u4e0b\uff1a\u9996\u5148\u8981\u6ce8\u610f\u7b2c\u4e00\u4f4d\u5c31\u662f0\u7684\u60c5\u51b5\uff0c\u7740\u5e76\u4e0d\u4ee3\u8868\u8fd9\u4f4d\u662f0\uff0c\u800c\u662f\u5ffd\u7565\u8fd9\u4f4d\uff0c\u6240\u4ee5\u6309\u7167\u516c\u5f0f\u5199\u4e2a\u7279\u6b8a\u7684\u7edf\u8ba1\u7684\u5c31OK\u4e86\u3002\u3002\u8fd8\u6709\u5c31\u662f\u53ef\u4ee5\u524d\u9762\u7684\u6570\u4f4d\u5df2\u7ecf\u4e0d\u80fd\u662fwindy\u6570\u4e86\uff0c\u5c31\u4e0d\u8981\u63a8\u4e0b\u53bb\u4e86\u3002\u3002\u540c\u65f6\u4e00\u5b9a\u8981\u5199\u4e2a\u66b4\u529b\u5bf9\u62cd\u3002\u3002\u5bf9\u62cd\u8981\u591a\u8003\u8651\u8fd9\u6837\u7684\u6570\u636e\uff1a1\uff1a 1-1000000\u8fd9\u6837\u7684.\u3002\u30022\uff1a1-99999\u8fd9\u6837\u7684\u3002\u30023: xxx-xxxxx\u8fd9\u6837\u7684\uff0c\u81f3\u5c11\u5dee2\u4f4d\u3002\u30024\uff1a\u5982\u679c\u8fd8\u4e0d\u653e\u5fc3\u968f\u673a\u4e2aN\u7ec4\u6765\u641e\u641e\u3002\u30025\uff1a\u6700\u597d\u7528long long\u514d\u5f97\u6ea2\u51fa\u3002\u30026\uff1a\u6ca1\u6709\u4e86\u3002\u3002 \u5bf9\u62cd\u5668\uff1a \u4ee3\u7801\uff1a<\/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\/267"}],"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=267"}],"version-history":[{"count":2,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":779,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/779"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}