{"id":128,"date":"2010-02-24T20:43:00","date_gmt":"2010-02-24T12:43:00","guid":{"rendered":"http:\/\/localhost\/?p=128"},"modified":"2010-02-24T20:43:00","modified_gmt":"2010-02-24T12:43:00","slug":"sgu_491","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=128","title":{"rendered":"SGU 491"},"content":{"rendered":"<p> \u5168\u4e16\u754c\u7b2c46\u4e2aA\u6389\u8fd9\u9053\u9898\u7684\u5509\u3002\u3002\u6fc0\u52a8\u6b7b\u4e86\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0003.gif\" \/><br \/>\u6fc0\u52a8\u5b8c\u4e86\u3002\u3002\u8bb2\u8bb2\u7b97\u6cd5\u5427\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0013.gif\" \/><br \/>\u9898\u76ee\u662f\u8bf4\u7ed9\u4e00\u4e2aN\u3002\u8ba9\u4f60\u6c42\u6709\u591a\u5c11\u5bf9A\u548cB\uff0c\u8ba9\u65b9\u7a0bAx+By=N\u6709\u81ea\u7136\u6570\u89e3\u3002\u3002<br \/>N&lt;=100000\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0004.gif\" \/><br \/>\u8fd9\u4e2aN\u5361\u7684\u592a\u7d27\u4e86\u3002\u3002\u6211\u82b1\u4e863\u4e2a\u5c0f\u65f6\u52a0\u901f\u7a0b\u5e8f\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><br \/>\u4e00\u5f00\u59cb\u6211\u7684\u60f3\u6cd5\u662f\u9996\u5148\u7b97\u51fa\u6240\u6709\u5c0f\u4e8eN\u7684\u6570\u7684\u56e0\u5b50\uff0c\u4e00\u4e2a\u6570\u7684\u56e0\u5b50\u4e2a\u6570\u662flogn\u7ea7\u522b\u7684\u3002<br \/>\u603b\u5171\u5c31\u662fNlogN\u8fd9\u4e0d\u662f\u95ee\u9898\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0018.gif\" \/><br \/>\u5173\u952e\u662f\u540e\u9762\u7684\uff0c\u65f6\u9650\u5361\u5f97\u592a\u7d27\u4e86\uff0c4s\uff0c\u6211\u4e00\u5f00\u59cb\u66b4\u529b\u679a\u4e3eAx\u7684\u503c\uff0c\u7136\u540eBy=N-Ax\u3002<br \/>\u90a3\u4e48Ax\u7684\u4efb\u4f55\u56e0\u5b50\u914d\u4e0aBy\u7684\u4efb\u4f55\u56e0\u5b50\u90fd\u662f\u89e3\u3002\u3002\u7136\u540e\u53bb\u91cd\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>\u770b\u4e00\u4e0b\u6211\u7684\u4f18\u5316\u4e4b\u8def\u5427\u3002\u3002\u4e0b\u9762\u7684\u65f6\u95f4\u8868\u793a\u6700\u5927\u6570\u636e\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0020.gif\" \/><br \/>\u4f7f\u7528set\u52a0\u4e0apair&lt;int,int&gt;\u6765\u53bb\u91cd\u3002\u300223s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><br \/>\u8bb2pair&lt;int,int&gt;\u538b\u7f29\u6210\u4e00\u4e2along long\u3002\u300221s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0009.gif\" \/><br \/>\u5148\u8bb2\u8fd9\u4e9blong long\u5b58\u4e0b\u6765\u3002\u518d\u6392\u5e8f\u4e4b\u540e\u53bb\u91cd\u3002\u30028s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0003.gif\" \/><br \/>\u4e00\u4e9b\u7ec6\u8282\u4e0a\u7684\u5c0f\u4f18\u5316\uff0c\u6bd4\u5982vector\u4f7f\u7528\u7531\u7d22\u5f15\u6539\u6210iterator\u4e4b\u7c7b\u7684\u3002\u30027s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0007.gif\" \/><br \/>\u5927\u53eb\u4e86\u4e00\u58f0TMD\uff0c\u4eba\u54c1\u7206\u53d1&nbsp;&nbsp;&nbsp;&nbsp;  6.2s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0009.gif\" \/><br \/>\u6655\u4e86\u3002\u3002\u5199\u4e86\u4e2ahash\u3002\u3002&nbsp;&nbsp;&nbsp;  MLE<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0016.gif\" \/><br \/>\u4f7f\u52b2\u6539Hash\u3002\u3002\u3002&nbsp;&nbsp;&nbsp;  \u8fd8\u662fMLE<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0024.gif\" \/><br \/>\u603b\u7b97\u6539\u597d\u4e86Hash&nbsp;&nbsp;&nbsp;  23.3s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0012.gif\" \/><br \/>\u9707\u7cbe\u4e86\u3002\u7528\u4e86Hash+set  15s<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0025.gif\" \/><br \/>\u649e\u6b7b\u3002\u3002\u5403\u996d\u53bb\u4e86\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0008.gif\" \/><br \/>\u5403\u996d\u597d\u4e86\u7ee7\u7eed\u60f3\u3002\u3002\u6211\u628a\u6700\u5feb\u7684\u90a3\u4e2a\u7b97\u6cd5\u7684\u7528\u65f6\u5206\u6790\u4e86\u4e00\u4e0b\u3002\u3002<br \/>\u53d1\u73b0\u8bfb\u51650s\u8f93\u51fa0s\u9884\u5904\u74061.6s\uff0c\u679a\u4e3e0.7s\uff0c\u6392\u5e8f+\u53bb\u91cd5s\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0013.gif\" \/><br \/>\u4e8e\u662f\u6211\u53d1\u73b0\u9884\u5904\u7406\u53ef\u4ee5\u8be5\u8fdb\u3002\u3002\u4e00\u5f00\u59cb\u6211\u662f\u66b4\u529b\u679a\u4e3e\u5e73\u65b9\u6839\u4ee5\u4e0b\u7684\u56e0\u5b50\u5e76\u7528set\u53bb\u91cd\u7684\uff0c\u53d1\u73b0\u66f4\u672c\u6ca1\u5fc5\u8981\u3002\u53ea\u8981\u7528vector\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u4e8e\u662f\u9884\u5904\u7406\u53d8\u62100.8s\u3002\u3002<br \/>\u8fd8\u662f\u8d85\u65f6\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_t_0024.gif\" \/><br \/>\u6700\u540e\u6211\u5feb\u7edd\u671b\u4e86\u3002\u3002\u4e8e\u662f\u6211\u60f3\u53ef\u80fd\u662f\u56e0\u4e3a\u6392\u5e8f\u7684\u4e1c\u897f\u592a\u591a\u4e86\u3002\u3002\u4e00\u80a1\u8111\u6392\u5e8f\u53ef\u80fd\u6162\u4e86\u70b9\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_t_0025.gif\" \/><br \/>\u4e8e\u662f\u6211\u5148\u679a\u4e3ea\u518d\u679a\u4e3ex\u3002\u3002\u7136\u540e\u7b97\u51fa\u6240\u6709\u53ef\u80fd\u7684b\u3002\u3002\u7136\u540e\u5bf9\u4e8e\u6bcf\u4e2aa\u53bb\u4e00\u6b21\u91cd\u3002\u3002<br \/>\u5b9e\u9645\u4e0a\u8fd9\u4e24\u4e2a\u7b97\u6cd5\u662f\u4e00\u6478\u4e00\u6837\u7684\u3002\u3002\u4f46\u662f\u8fd9\u4e2a\u5c31AC\u4e86\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_j_0023.gif\" \/><br \/>\u7d2f\u554a\u3002\u3002\u3002\u3002\u3002<img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/other_site\/img_baidu_t_0017.gif\" \/><br \/>Code\uff1a<\/p>\n<p>#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;set&gt;<br \/>#include&lt;ctime&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>using namespace std;<br \/>const int maxn=100000+1;int n;<br \/>vector&lt;int&gt; A[maxn];<br \/>typedef vector&lt;int&gt;::iterator it;<br \/>typedef vector&lt;int&gt;::reverse_iterator rit;<br \/>typedef long long ll;<br \/>void Cal(int x)<br \/>{<br \/>    static int tmp[10000];<br \/>    int cnt=0;<br \/>    for(int i=1;i*i&lt;=x;i++)if(x%i==0)<br \/>        tmp[cnt++]=i,tmp[cnt++]=x\/i;<br \/>    sort(tmp,tmp+cnt);A[x].push_back(tmp[0]);<br \/>    for(int j=1;j&lt;cnt;j++)<br \/>        if(tmp[j]!=tmp[j-1])<br \/>            A[x].push_back(tmp[j]);<br \/>}<br \/>int Ans[maxn*50];<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    int o=clock();<br \/>    cin&gt;&gt;n;<br \/>    for(int i=1;i&lt;n;i++) Cal(i);<br \/>    int ans=0;<br \/>    for(int a=1;a&lt;n;a++)<br \/>    {<br \/>        int*end=Ans;<br \/>        for(int l=a;l&lt;n;l+=a)<br \/>        {<br \/>            int r=n-l;<br \/>            for(rit i=A[r].rbegin();i!=A[r].rend();i++)<br \/>                if(*i&gt;a) *(end++)=*i;<br \/>                else break;<br \/>        }<br \/>        if(Ans==end) continue;<br \/>        sort(Ans,end);<br \/>        ans++;<br \/>        for(int*i=Ans+1;i!=end;i++)<br \/>            if(*i!=*(i-1)) ans++;<br \/>    }<br \/>    cout&lt;&lt;ans&lt;&lt;endl;<br \/>}<br \/>\u672c\u9ad8\u4eae\u4ee3\u7801\u4f7f\u7528codeHl\u751f\u6210\uff0c   <br \/>  loading&#8230; loading&#8230; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5168\u4e16\u754c\u7b2c46\u4e2aA\u6389\u8fd9\u9053\u9898\u7684\u5509\u3002\u3002\u6fc0\u52a8\u6b7b\u4e86\u3002\u3002\u6fc0\u52a8\u5b8c\u4e86\u3002\u3002\u8bb2\u8bb2\u7b97\u6cd5\u5427\u3002\u9898\u76ee\u662f\u8bf4\u7ed9\u4e00\u4e2aN\u3002\u8ba9\u4f60\u6c42\u6709\u591a\u5c11\u5bf9A\u548cB\uff0c\u8ba9\u65b9\u7a0bAx+By=N\u6709\u81ea\u7136\u6570\u89e3\u3002\u3002N&lt;=100000\u3002\u3002\u8fd9\u4e2aN\u5361\u7684\u592a\u7d27\u4e86\u3002\u3002\u6211\u82b1\u4e863\u4e2a\u5c0f\u65f6\u52a0\u901f\u7a0b\u5e8f\u3002\u3002\u4e00\u5f00\u59cb\u6211\u7684\u60f3\u6cd5\u662f\u9996\u5148\u7b97\u51fa\u6240\u6709\u5c0f\u4e8eN\u7684\u6570\u7684\u56e0\u5b50\uff0c\u4e00\u4e2a\u6570\u7684\u56e0\u5b50\u4e2a\u6570\u662flogn\u7ea7\u522b\u7684\u3002\u603b\u5171\u5c31\u662fNlogN\u8fd9\u4e0d\u662f\u95ee\u9898\u3002\u3002\u5173\u952e\u662f\u540e\u9762\u7684\uff0c\u65f6\u9650\u5361\u5f97\u592a\u7d27\u4e86\uff0c4s\uff0c\u6211\u4e00\u5f00\u59cb\u66b4\u529b\u679a\u4e3eAx\u7684\u503c\uff0c\u7136\u540eBy=N-Ax\u3002\u90a3\u4e48Ax\u7684\u4efb\u4f55\u56e0\u5b50\u914d\u4e0aBy\u7684\u4efb\u4f55\u56e0\u5b50\u90fd\u662f\u89e3\u3002\u3002\u7136\u540e\u53bb\u91cd\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u770b\u4e00\u4e0b\u6211\u7684\u4f18\u5316\u4e4b\u8def\u5427\u3002\u3002\u4e0b\u9762\u7684\u65f6\u95f4\u8868\u793a\u6700\u5927\u6570\u636e\u3002\u3002\u4f7f\u7528set\u52a0\u4e0apair&lt;int,int&gt;\u6765\u53bb\u91cd\u3002\u300223s\u8bb2pair&lt;int,int&gt;\u538b\u7f29\u6210\u4e00\u4e2along long\u3002\u300221s\u5148\u8bb2\u8fd9\u4e9blong long\u5b58\u4e0b\u6765\u3002\u518d\u6392\u5e8f\u4e4b\u540e\u53bb\u91cd\u3002\u30028s\u4e00\u4e9b\u7ec6\u8282\u4e0a\u7684\u5c0f\u4f18\u5316\uff0c\u6bd4\u5982vector\u4f7f\u7528\u7531\u7d22\u5f15\u6539\u6210iterator\u4e4b\u7c7b\u7684\u3002\u30027s\u5927\u53eb\u4e86\u4e00\u58f0TMD\uff0c\u4eba\u54c1\u7206\u53d1&nbsp;&nbsp;&nbsp;&nbsp; 6.2s\u6655\u4e86\u3002\u3002\u5199\u4e86\u4e2ahash\u3002\u3002&nbsp;&nbsp;&nbsp; MLE\u4f7f\u52b2\u6539Hash\u3002\u3002\u3002&nbsp;&nbsp;&nbsp; \u8fd8\u662fMLE\u603b\u7b97\u6539\u597d\u4e86Hash&nbsp;&nbsp;&nbsp; 23.3s\u9707\u7cbe\u4e86\u3002\u7528\u4e86Hash+set 15s\u649e\u6b7b\u3002\u3002\u5403\u996d\u53bb\u4e86\u3002\u3002\u5403\u996d\u597d\u4e86\u7ee7\u7eed\u60f3\u3002\u3002\u6211\u628a\u6700\u5feb\u7684\u90a3\u4e2a\u7b97\u6cd5\u7684\u7528\u65f6\u5206\u6790\u4e86\u4e00\u4e0b\u3002\u3002\u53d1\u73b0\u8bfb\u51650s\u8f93\u51fa0s\u9884\u5904\u74061.6s\uff0c\u679a\u4e3e0.7s\uff0c\u6392\u5e8f+\u53bb\u91cd5s\u3002\u3002\u4e8e\u662f\u6211\u53d1\u73b0\u9884\u5904\u7406\u53ef\u4ee5\u8be5\u8fdb\u3002\u3002\u4e00\u5f00\u59cb\u6211\u662f\u66b4\u529b\u679a\u4e3e\u5e73\u65b9\u6839\u4ee5\u4e0b\u7684\u56e0\u5b50\u5e76\u7528set\u53bb\u91cd\u7684\uff0c\u53d1\u73b0\u66f4\u672c\u6ca1\u5fc5\u8981\u3002\u53ea\u8981\u7528vector\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u4e8e\u662f\u9884\u5904\u7406\u53d8\u62100.8s\u3002\u3002\u8fd8\u662f\u8d85\u65f6\u3002\u3002\u6700\u540e\u6211\u5feb\u7edd\u671b\u4e86\u3002\u3002\u4e8e\u662f\u6211\u60f3\u53ef\u80fd\u662f\u56e0\u4e3a\u6392\u5e8f\u7684\u4e1c\u897f\u592a\u591a\u4e86\u3002\u3002\u4e00\u80a1\u8111\u6392\u5e8f\u53ef\u80fd\u6162\u4e86\u70b9\u3002\u3002\u4e8e\u662f\u6211\u5148\u679a\u4e3ea\u518d\u679a\u4e3ex\u3002\u3002\u7136\u540e\u7b97\u51fa\u6240\u6709\u53ef\u80fd\u7684b\u3002\u3002\u7136\u540e\u5bf9\u4e8e\u6bcf\u4e2aa\u53bb\u4e00\u6b21\u91cd\u3002\u3002\u5b9e\u9645\u4e0a\u8fd9\u4e24\u4e2a\u7b97\u6cd5\u662f\u4e00\u6478\u4e00\u6837\u7684\u3002\u3002\u4f46\u662f\u8fd9\u4e2a\u5c31AC\u4e86\u3002\u3002\u7d2f\u554a\u3002\u3002\u3002\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;set&gt;#include&lt;ctime&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxn=100000+1;int n;vector&lt;int&gt; A[maxn];typedef vector&lt;int&gt;::iterator it;typedef vector&lt;int&gt;::reverse_iterator rit;typedef long long ll;void Cal(int x){ static int tmp[10000]; int cnt=0; for(int i=1;i*i&lt;=x;i++)if(x%i==0) tmp[cnt++]=i,tmp[cnt++]=x\/i; sort(tmp,tmp+cnt);A[x].push_back(tmp[0]); for(int j=1;j&lt;cnt;j++) if(tmp[j]!=tmp[j-1]) A[x].push_back(tmp[j]);}int Ans[maxn*50];int main(){ \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin); int o=clock(); cin&gt;&gt;n; for(int i=1;i&lt;n;i++) Cal(i); int ans=0; for(int a=1;a&lt;n;a++) { int*end=Ans; [&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\/128"}],"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=128"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}