{"id":188,"date":"2010-03-26T17:56:00","date_gmt":"2010-03-26T09:56:00","guid":{"rendered":"http:\/\/localhost\/?p=188"},"modified":"2010-03-26T17:56:00","modified_gmt":"2010-03-26T09:56:00","slug":"vijos_camphor_tree-2","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=188","title":{"rendered":"Vijos \u9999\u6a1f\u6811"},"content":{"rendered":"<p> \u989d\u3002\u3002VIJOS\u590d\u6d3b\u4e86\u3002\u3002\u6240\u4ee5\u6211\u53bbA\u4e86\u8fd9\u9053\u9898\u3002\u3002<a href=\"http:\/\/www.vijos.cn\/Problem_Show.asp?id=1703\" target=\"_blank\">www.vijos.cn\/Problem_Show.asp<\/a><br \/>\u9898\u76ee\u662f\u8bf4\u7ed9\u4f60n\u4e2a\u6570\uff0c\u90fd\u5c0f\u4e8e10^5\uff0c\u7136\u540e\u8ba9\u4f60\u6c42\u51fa\u5176\u4e2d\u4e00\u4e2a\u5b50\u5e8f\u5217\uff08\u8fde\u4e0d\u8fde\u7eed\u65e0\u6240\u8c13\uff0c\u53ea\u8981\u987a\u5e8f\u662f\u539f\u5e8f\u5217\u7684\u987a\u5e8f\u5c31OK\uff09\u3002\u3002 \u76f8\u90bb\u4e24\u4e2a\u6570\u4e0d\u4e92\u8d28\u3002\u3002\u8ba9\u4f60\u6c42\u8fd9\u4e2a\u5e8f\u5217\u7684\u6700\u5927\u957f\u5ea6\u3002\u3002n&lt;=100000<br \/>\u5f88\u660e\u663e\u66b4\u529bDP\u662f\u4f1a\u60b2\u5267\u7684\uff0c\u5982\u679c\u4f60\u7528Dpi\u8868\u793a\u7b2ci\u4e2a\u6570\u7ed3\u5c3e\u7684\u6700\u957f\u957f\u5ea6\u7136\u540eO(n)\u679a\u4e3e\u524d\u4e00\u4e2a\u7684\u8bdd\u662fO(n^2)\u7684\u3002\u5173\u952e\u662f\u5229\u7528\u9898\u76ee\u7684\u6027\u8d28\u3002<br \/>\u6ce8\u610f\u5230\u4e0d\u4e92\u8d28\u7684\u6570\u4e00\u5b9a\u6709\u4e00\u4e2a\u516c\u5171\u7684\u8d28\u56e0\u5b50\uff0c\u5c31\u7b80\u5355\u4e86\u3002\u9996\u5148\u7b97\u51fa10^5\u4e00\u4e0b\u6bcf\u4e2a\u8d28\u6570\uff0c\u7136\u540e\u5f00\u4e2a\u6570\u7ec4\u4fdd\u5b58\u6bcf\u4e2a\u5f53\u524d\u4ee5\u7b2ci\u4e2a\u8d28\u6570\u7684\u500d\u6570\u7ed3\u5c3e\u7684\u6570\u5217\u7684\u6700\u957f\u503c\uff0c\u7136 \u540e\u5bf9\u4e8e\u6bcf\u4e2a\u6570\u679a\u4e3e\u4ed6\u7684\u6bcf\u4e2a\u8d28\u56e0\u5b50\u8ba1\u7b97\u5e76\u66f4\u65b0\u4e00\u4e0b\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>\u5173\u952e\u662f\u4e00\u4e2a\u6570\u7684\u8d28\u56e0\u5b50\u6570\u76ee\u663e\u7136\u662fO(logn)\u7ea7\u522b\u7684\uff0c\u5e76\u4e14\u9884\u5148\u5904\u7406\u4e5f\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u679a\u4e3e\u91cf\u3002\u3002\u6211\u611f\u89c9\u5e94\u8be5\u4f1a\u5f88\u5feb\uff0c\u6ca1\u60f3\u52300ms\u79d2\u6740\uff0c\u723d\u989d\u3002\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;cstring&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>using namespace std;<br \/>const int inf=~0U&gt;&gt;1,maxn=100000+1,maxp=maxn&gt;&gt;3;<br \/>bool NotPrime[maxn]={0};<br \/>int Ps[maxp],cnt=0;<br \/>void GetPrime()<br \/>{<br \/>    for(int i=2;i*i&lt;maxn;i++)<br \/>    {<br \/>        if(!NotPrime[i])<br \/>        {<br \/>            for(int j=i*2;j&lt;maxn;j+=i)<br \/>                NotPrime[j]=true;<br \/>        }<br \/>    }<br \/>    for(int i=2;i&lt;maxn;i++)<br \/>        if(!NotPrime[i])<br \/>            Ps[cnt++]=i;<br \/>}<br \/>int Max[maxp],pnt,Tmp[1000];<br \/>void GetDiv(int p)<br \/>{<br \/>    pnt=0;<br \/>    for(int i=0;i&lt;cnt;i++)<br \/>    {<br \/>        int t=Ps[i];if(t*t&gt;p)break;<br \/>        if(p%t==0)<br \/>        {<br \/>            Tmp[pnt++]=i;<br \/>            while(p%t==0)p\/=t;<br \/>        }<br \/>    }<br \/>    if(p!=1)<br \/>    {<br \/>        int i=lower_bound(Ps,Ps+cnt,p)-Ps;<br \/>        Tmp[pnt++]=i;<br \/>    }<br \/>}<br \/>void solve()<br \/>{<br \/>    int n,x;scanf(&quot;%d&quot;,&amp;n);<br \/>    while(n&#8211;)<br \/>    {<br \/>        scanf(&quot;%d&quot;,&amp;x);<br \/>        GetDiv(x);<br \/>        int ret=0;<br \/>        rep(i,pnt)ret=max(ret,Max[Tmp[i]]);<br \/>        ret++;<br \/>        rep(i,pnt) Max[Tmp[i]]=ret;<br \/>    }<br \/>    int ans=0;<br \/>    rep(i,cnt) ans=max(ans,Max[i]);<br \/>    printf(&quot;%dn&quot;,ans);<br \/>}<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    GetPrime();<br \/>    solve();<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u989d\u3002\u3002VIJOS\u590d\u6d3b\u4e86\u3002\u3002\u6240\u4ee5\u6211\u53bbA\u4e86\u8fd9\u9053\u9898\u3002\u3002www.vijos.cn\/Problem_Show.asp\u9898\u76ee\u662f\u8bf4\u7ed9\u4f60n\u4e2a\u6570\uff0c\u90fd\u5c0f\u4e8e10^5\uff0c\u7136\u540e\u8ba9\u4f60\u6c42\u51fa\u5176\u4e2d\u4e00\u4e2a\u5b50\u5e8f\u5217\uff08\u8fde\u4e0d\u8fde\u7eed\u65e0\u6240\u8c13\uff0c\u53ea\u8981\u987a\u5e8f\u662f\u539f\u5e8f\u5217\u7684\u987a\u5e8f\u5c31OK\uff09\u3002\u3002 \u76f8\u90bb\u4e24\u4e2a\u6570\u4e0d\u4e92\u8d28\u3002\u3002\u8ba9\u4f60\u6c42\u8fd9\u4e2a\u5e8f\u5217\u7684\u6700\u5927\u957f\u5ea6\u3002\u3002n&lt;=100000\u5f88\u660e\u663e\u66b4\u529bDP\u662f\u4f1a\u60b2\u5267\u7684\uff0c\u5982\u679c\u4f60\u7528Dpi\u8868\u793a\u7b2ci\u4e2a\u6570\u7ed3\u5c3e\u7684\u6700\u957f\u957f\u5ea6\u7136\u540eO(n)\u679a\u4e3e\u524d\u4e00\u4e2a\u7684\u8bdd\u662fO(n^2)\u7684\u3002\u5173\u952e\u662f\u5229\u7528\u9898\u76ee\u7684\u6027\u8d28\u3002\u6ce8\u610f\u5230\u4e0d\u4e92\u8d28\u7684\u6570\u4e00\u5b9a\u6709\u4e00\u4e2a\u516c\u5171\u7684\u8d28\u56e0\u5b50\uff0c\u5c31\u7b80\u5355\u4e86\u3002\u9996\u5148\u7b97\u51fa10^5\u4e00\u4e0b\u6bcf\u4e2a\u8d28\u6570\uff0c\u7136\u540e\u5f00\u4e2a\u6570\u7ec4\u4fdd\u5b58\u6bcf\u4e2a\u5f53\u524d\u4ee5\u7b2ci\u4e2a\u8d28\u6570\u7684\u500d\u6570\u7ed3\u5c3e\u7684\u6570\u5217\u7684\u6700\u957f\u503c\uff0c\u7136 \u540e\u5bf9\u4e8e\u6bcf\u4e2a\u6570\u679a\u4e3e\u4ed6\u7684\u6bcf\u4e2a\u8d28\u56e0\u5b50\u8ba1\u7b97\u5e76\u66f4\u65b0\u4e00\u4e0b\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u5173\u952e\u662f\u4e00\u4e2a\u6570\u7684\u8d28\u56e0\u5b50\u6570\u76ee\u663e\u7136\u662fO(logn)\u7ea7\u522b\u7684\uff0c\u5e76\u4e14\u9884\u5148\u5904\u7406\u4e5f\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u679a\u4e3e\u91cf\u3002\u3002\u6211\u611f\u89c9\u5e94\u8be5\u4f1a\u5f88\u5feb\uff0c\u6ca1\u60f3\u52300ms\u79d2\u6740\uff0c\u723d\u989d\u3002\u3002Code\uff1a#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)#define pb push_backusing namespace std;const int inf=~0U&gt;&gt;1,maxn=100000+1,maxp=maxn&gt;&gt;3;bool NotPrime[maxn]={0};int Ps[maxp],cnt=0;void GetPrime(){ for(int i=2;i*i&lt;maxn;i++) { if(!NotPrime[i]) { for(int j=i*2;j&lt;maxn;j+=i) NotPrime[j]=true; } } for(int i=2;i&lt;maxn;i++) if(!NotPrime[i]) Ps[cnt++]=i;}int Max[maxp],pnt,Tmp[1000];void GetDiv(int p){ pnt=0; for(int i=0;i&lt;cnt;i++) { int t=Ps[i];if(t*t&gt;p)break; if(p%t==0) { Tmp[pnt++]=i; while(p%t==0)p\/=t; } } if(p!=1) { int i=lower_bound(Ps,Ps+cnt,p)-Ps; Tmp[pnt++]=i; }}void solve(){ int n,x;scanf(&quot;%d&quot;,&amp;n); while(n&#8211;) { [&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\/188"}],"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=188"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}