{"id":138,"date":"2010-03-05T18:02:00","date_gmt":"2010-03-05T10:02:00","guid":{"rendered":"http:\/\/localhost\/?p=138"},"modified":"2010-03-05T18:02:00","modified_gmt":"2010-03-05T10:02:00","slug":"vijos_1701_local_maxima","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=138","title":{"rendered":"[VIJOS 1701] Local Maxima"},"content":{"rendered":"<p> \u989d\u3002\u3002\u6700\u4e3aVIJOS\u56de\u5f52\u4e4b\u540e\u505a\u7684\u7b2c\u4e00\u9898\u3002\u8fd8\u662f\u86ee\u6709\u610f\u601d\u7684\u3002\u3002<br \/><a href=\"http:\/\/www.vijos.cn\/Problem_Show.asp?id=1701\" target=\"_blank\">\u4f20\u9001\u95e8<\/a><br \/>\u9996\u5148\u53ef\u4ee5\u770b\u51fa\u7b54\u6848\u662f1\u5230n\u7684\u5012\u6570\u548c\u3002\u3002<br \/>\u6709\u4e24\u4e2a\u529e\u6cd5\u3002\u3002\u4e00\u4e2a\u662f\u6211\u5f00\u59cb\u60f3\u5230\u7684\u5c31\u662f\u8bbeF(x)\u4e3a1\u5230x\u7684\u6392\u5217\u7684\u7b54\u6848\u3002<br \/>\u90a3\u4e48\u82e5\u8fd9\u4e2a\u6392\u5217\u7b2c\u4e00\u4e2a\u662f1\u3002\u90a3\u4e48\u5c31\u662fF(x-1)+1\u5426\u5219\u5728\u4e2d\u95f4\u76841\u53ef\u4ee5\u5ffd\u7565\u6389\uff0c\u5c31\u662fF(x-1)\u3002\u3002<br \/>\u90a3\u4e48F(x)=( F(x-1)+1 )\/x +F(x-1)*(x-1)\/x\u3002\u3002<br \/>\u5c31\u662fF(x)=F(x-1)+1\/x\u3002\u3002\u3002<br \/>\u8fd9\u4e2a\u65b9\u6cd5\u53ea\u6709\u6211\u8fd9\u6837\u83dc\u7684\u4eba\u624d\u60f3\u7684\u51fa\u6765\u56e7\u3002\u3002<br \/>\u4e00\u822c\u6765\u8bf4\u7b2ci\u4e2a\u6570\u4e3aLocal Maxima\u7684\u6982\u7387\u5c31\u662f\u4ed6\u4e3a\u524di\u4e2a\u4e2d\u6700\u5927\u7684\u6982\u7387\uff0c\u5c31\u662f1\/i\u3002\u3002<br \/>\u7136\u540e+\u8d77\u6765\u3002\u3002<br \/>\u4e0d\u8fc7\u6570\u636e\u8303\u56f4\u592aTMD\u5927\u4e86\u3002\u3002<br \/>\u6211\u4e00\u5f00\u59cb\u60f3\u662f\u4e0d\u662f\u8981\u7528\u77e9\u9635\u52a0\u901f\uff0c\u611f\u89c9\u4e0d\u662f\u9f50\u6b21\u7684\u641e\u4e0d\u51fa\u6765\u3002\u3002\u3002<br \/>\u6700\u540ewiki\u4e86\u4e00\u4e0b\u8c03\u548c\u6570\u5217\uff0c\u53d1\u73b0\u539f\u6765\u662f\u6709\u516c\u5f0f\u7684\u3002\u3002<br \/><a href=\"http:\/\/zh.wikipedia.org\/wiki\/%E6%AC%A7%E6%8B%89-%E9%A9%AC%E6%AD%87%E7%BD%97%E5%B0%BC%E5%B8%B8%E6%95%B0\" target=\"_blank\">zh.wikipedia.org\/wiki\/%E6%AC%A7%E6%8B%89-%E9%A9%AC%E6%AD%87%E7%BD%97%E5%B0%BC%E5%B8%B8%E6%95%B0<\/a><br \/>\u56e0\u4e3a\u7cbe\u5ea6\u7684\u95ee\u9898\uff0c\u5bf9\u4e8en&lt;=10^6\u6b21\u65b9\u7684\u65f6\u5019\u3002\u3002\u66b4\u529b\u8ba1\u7b97\uff0c<br \/>\u5426\u5219\u4f7f\u7528\u516c\u5f0f\u3002<br \/>Code\uff1a<br \/>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;cmath&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>using namespace std;<br \/>const int inf=~0U&gt;&gt;1;<br \/>const int limit=1e6;<br \/>int main()<br \/>{<br \/>    int n;cin&gt;&gt;n;double ans=0;<br \/>    if(n&lt;=limit)<br \/>        for(double i=1;i&lt;=n;i++)<br \/>            ans+=1\/i;<br \/>    else<br \/>        ans=log((double)n)+0.57721566490153286060651209;<br \/>    printf(&quot;%0.8lfn&quot;,ans);<br \/>}P.S\u6211\u7684vijos\u53f7\u7531\u4e8e\u6ce8\u518c\u7684\u6bd4\u8f83\u65e9\u3002\u4e0d\u53ebWJMZBMR\u3002\u3002\u597d\u50cf\u662f453844077\u56e7\u3002\u3002\u6211\u5728\u60f3\u662f\u4e0d\u662f\u4e3a\u4e86\u7edf\u4e00\u98ce\u683c\u5c31\u4e0d\u8981\u539f\u6765\u7684\u53f7\u4e86\u53c8\u820d\u4e0d\u5f97100\u591a\u9053\u9898\u76ee\u56e7\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u989d\u3002\u3002\u6700\u4e3aVIJOS\u56de\u5f52\u4e4b\u540e\u505a\u7684\u7b2c\u4e00\u9898\u3002\u8fd8\u662f\u86ee\u6709\u610f\u601d\u7684\u3002\u3002\u4f20\u9001\u95e8\u9996\u5148\u53ef\u4ee5\u770b\u51fa\u7b54\u6848\u662f1\u5230n\u7684\u5012\u6570\u548c\u3002\u3002\u6709\u4e24\u4e2a\u529e\u6cd5\u3002\u3002\u4e00\u4e2a\u662f\u6211\u5f00\u59cb\u60f3\u5230\u7684\u5c31\u662f\u8bbeF(x)\u4e3a1\u5230x\u7684\u6392\u5217\u7684\u7b54\u6848\u3002\u90a3\u4e48\u82e5\u8fd9\u4e2a\u6392\u5217\u7b2c\u4e00\u4e2a\u662f1\u3002\u90a3\u4e48\u5c31\u662fF(x-1)+1\u5426\u5219\u5728\u4e2d\u95f4\u76841\u53ef\u4ee5\u5ffd\u7565\u6389\uff0c\u5c31\u662fF(x-1)\u3002\u3002\u90a3\u4e48F(x)=( F(x-1)+1 )\/x +F(x-1)*(x-1)\/x\u3002\u3002\u5c31\u662fF(x)=F(x-1)+1\/x\u3002\u3002\u3002\u8fd9\u4e2a\u65b9\u6cd5\u53ea\u6709\u6211\u8fd9\u6837\u83dc\u7684\u4eba\u624d\u60f3\u7684\u51fa\u6765\u56e7\u3002\u3002\u4e00\u822c\u6765\u8bf4\u7b2ci\u4e2a\u6570\u4e3aLocal Maxima\u7684\u6982\u7387\u5c31\u662f\u4ed6\u4e3a\u524di\u4e2a\u4e2d\u6700\u5927\u7684\u6982\u7387\uff0c\u5c31\u662f1\/i\u3002\u3002\u7136\u540e+\u8d77\u6765\u3002\u3002\u4e0d\u8fc7\u6570\u636e\u8303\u56f4\u592aTMD\u5927\u4e86\u3002\u3002\u6211\u4e00\u5f00\u59cb\u60f3\u662f\u4e0d\u662f\u8981\u7528\u77e9\u9635\u52a0\u901f\uff0c\u611f\u89c9\u4e0d\u662f\u9f50\u6b21\u7684\u641e\u4e0d\u51fa\u6765\u3002\u3002\u3002\u6700\u540ewiki\u4e86\u4e00\u4e0b\u8c03\u548c\u6570\u5217\uff0c\u53d1\u73b0\u539f\u6765\u662f\u6709\u516c\u5f0f\u7684\u3002\u3002zh.wikipedia.org\/wiki\/%E6%AC%A7%E6%8B%89-%E9%A9%AC%E6%AD%87%E7%BD%97%E5%B0%BC%E5%B8%B8%E6%95%B0\u56e0\u4e3a\u7cbe\u5ea6\u7684\u95ee\u9898\uff0c\u5bf9\u4e8en&lt;=10^6\u6b21\u65b9\u7684\u65f6\u5019\u3002\u3002\u66b4\u529b\u8ba1\u7b97\uff0c\u5426\u5219\u4f7f\u7528\u516c\u5f0f\u3002Code\uff1a#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cmath&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int inf=~0U&gt;&gt;1;const int limit=1e6;int main(){ int n;cin&gt;&gt;n;double ans=0; if(n&lt;=limit) for(double i=1;i&lt;=n;i++) ans+=1\/i; else ans=log((double)n)+0.57721566490153286060651209; printf(&quot;%0.8lfn&quot;,ans);}P.S\u6211\u7684vijos\u53f7\u7531\u4e8e\u6ce8\u518c\u7684\u6bd4\u8f83\u65e9\u3002\u4e0d\u53ebWJMZBMR\u3002\u3002\u597d\u50cf\u662f453844077\u56e7\u3002\u3002\u6211\u5728\u60f3\u662f\u4e0d\u662f\u4e3a\u4e86\u7edf\u4e00\u98ce\u683c\u5c31\u4e0d\u8981\u539f\u6765\u7684\u53f7\u4e86\u53c8\u820d\u4e0d\u5f97100\u591a\u9053\u9898\u76ee\u56e7\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\/138"}],"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=138"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}