{"id":24,"date":"2009-11-14T19:30:00","date_gmt":"2009-11-14T11:30:00","guid":{"rendered":"http:\/\/localhost\/?p=24"},"modified":"2009-11-14T19:30:00","modified_gmt":"2009-11-14T11:30:00","slug":"the_sgu_347-357_part_1","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=24","title":{"rendered":"sgu 347-357 \u90e8\u5206\uff081\uff09"},"content":{"rendered":"<p> <img decoding=\"async\" src=\"http:\/\/wjmzbmr.com\/wp-content\/uploads\/pic\/92559b79283199da0bd1874f.jpg\" small=\"0\" class=\"blogimg\" \/><br \/>\u53c2\u52a0\u4e86\u865a\u62df\u6bd4\u8d5b11\u9053\u53ea\u505a\u4e865\u9053\u3002\u3002SB\u963f\u3002\u3002<br \/>346\u548c353\u90fd\u662f\u6a21\u62df\u7684\u9898\u76ee\u3002\u3002\u61d2\u5f97\u505a\u4e86\u3002\u3002<br \/>347\u3002\u3002\u770b\u4ee3\u7801\u5427\u3002\u3002<br \/>Code\u3002\u3002<br \/>#include&lt;iostream&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;algorithm&gt;<br \/>using namespace std;<br \/>const int maxn=100+10;<br \/>string A[maxn];<br \/>bool cmp(const string&amp;A,const string&amp;B)<br \/>{<br \/>return (A+B)&lt;(B+A);<br \/>}<br \/>int main()<br \/>{<br \/>int N;cin&gt;&gt;N;<br \/>for(int i=0;i&lt;N;i++)<br \/>cin&gt;&gt;A[i];<br \/>sort(A,A+N,cmp);<br \/>for(int i=0;i&lt;N;i++)<br \/>cout&lt;&lt;A[i];<br \/>cout&lt;&lt;endl;<br \/>}<br \/>350\u3002\u3002<br \/>\u6709\u70b9\u610f\u601d\u7684\u9898\u76ee\u3002\u3002<br \/>\u9996\u5148\u5982\u679c\u6709\u4e00\u4e2a\u89e3\u3002\u3002\u90a3\u4e48\u628a\u8fd9\u4e9b\u6570\u5168\u90e8xor\u4e0a\u4e00\u4e2a\u6570\u7684\u8bdd\u3002\u3002\u8fd8\u662f\u4e00\u4e2a\u89e3\u3002\u3002<br \/>\u56e0\u4e3a(a xor x) xor (b xor x)=(a xor b) xor (x xor x)= a xor b xor 0= a xor b\u3002\u3002\u3002<br \/>\u6240\u4ee5\u5c31\u5f53\u91cc\u9762\u6709\u4e00\u4e2a0\u597d\u4e86\u3002\u3002<br \/>\u7136\u540e\u7279\u5224\u6389M\uff1d1\u7684\u60c5\u51b5\u3002\u3002<br \/>\u90a3\u4e48\u6ce8\u610f\u5230\u3002\u3002\u5982\u679cB\u4e2d\u6709\u4e24\u4e2a\u6570A\u548cB\u3002\u3002A xor B\uff1d\u53e6\u4e00\u4e2a\u6570C\u3002\u3002<br \/>\u90a3\u4e48A\u548cB\u5fc5\u7136\u6709\u516c\u5171\u7684\u5143\u7d20\u3002\u3002<br \/>\u90a3\u4e48\u5c31\u5f88\u7b80\u5355\u4e86\u3002\u3002\u627e\u4e24\u4e2a\u6709\u516c\u5171\u5143\u7d20\u7684B\u4e2d\u7684\u6570i,j\u3002\u3002\u5f3a\u884c\u5c06\u5b83\u4eec\u7684\u516c\u5171\u5143\u7d20\u8bbe\u4e3a0\u3002\u3002<br \/>\u90a3\u4e48\u73b0\u5728\u5c31\u67093\u4e2a\u6570\u4e860\uff0ci,j\u3002\u3002<br \/>\u90a3\u4e48\u53ea\u8981\u627e\u5176\u4ed6\u7684\u67090\u7684\u5143\u7d20\u5c31\u53ef\u4ee5\u6c42\u51fa\u4e00\u4e2a\u89e3\u4e86\u3002\u3002\u600e\u4e48\u6c42\u627e\u5462\uff1f<br \/>\u5982\u679cB\u4e2d\u6570x\u4e0d\u662fi xor j\u3002\u3002\u53c8\u8ddfi\u548cj\u90fd\u6709\u516c\u5171\u5143\u7d20\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u516c\u5171\u5143\u7d20\u53ea\u80fd\u662f0\u4e86\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u6570\u5c31\u5c5e\u4e8e\u89e3\u4e86\u3002\u3002\u3002<br \/>\u5c31\u8fd9\u6837\u627e\u6570\u3002\u3002\u3002<br \/>#include&lt;iostream&gt;<\/p>\n<p>#define REP(i,n) for(int i=0;i&lt;n;i++)<br \/>using namespace std;<br \/>const int maxn=100;<br \/>int M,B[maxn];<br \/>bool HaveCommon(int i,int j,int&amp;k)<br \/>{<br \/> int now=B[i]^B[j];<br \/> for(k=0;k&lt;M;k++)<br \/>  if(B[k]==now)<br \/>   return true;<br \/> return false;<br \/>}<br \/>int main()<br \/>{<br \/> cin&gt;&gt;M;<br \/> REP(i,M) cin&gt;&gt;B[i]; <br \/> if(M==1)<br \/> {<br \/>  cout&lt;&lt;(B[0]-1)&lt;&lt;&quot; &quot;&lt;&lt;(B[0]^(B[0]-1))&lt;&lt;endl;<br \/>  return 0;<br \/> }<br \/> int ans[maxn];ans[0]=0;int i,j,k;<br \/> bool mark[maxn]={0};<br \/> for(i=0;i&lt;M;i++)<br \/>  for(j=i+1;j&lt;M;j++)<br \/>   if(HaveCommon(i,j,k))<br \/>   {<br \/>    ans[1]=B[i],ans[2]=B[j],mark[i]=mark[j]=mark[k]=true;<br \/>    goto out;<br \/>   }<br \/> out:  <br \/> int cnt=3,t;<br \/> for(int o=0;o&lt;M;o++) if(!mark[o])<br \/>  if(HaveCommon(o,i,t)&amp;&amp;HaveCommon(o,j,t))<br \/>   ans[cnt++]=B[o];<br \/> cout&lt;&lt;ans[0];<br \/> for(int i=1;i&lt;cnt;i++)<br \/>  cout&lt;&lt;&quot; &quot;&lt;&lt;ans[i];<br \/> cout&lt;&lt;endl;<br \/>}355\u3002\u3002\u3002<br \/>\u6784\u9020\u9898\u3002\u3002\u5f88\u660e\u663e\u7b54\u6848\u662flogN+1&#8230;<br \/>\u67d3\u8272\u7684\u8bdd\u53ea\u8981\u67d3\u6210\u7d20\u56e0\u6570\u4e2a\u6570\u5c31OK\u4e86\u3002\u3002<br \/>#include&lt;iostream&gt;<br \/>using namespace std;<br \/>int num(int p)<br \/>{<br \/> int cnt=0;<br \/> while(p%2==0)<br \/> {cnt++;p\/=2;}<br \/> while(p%3==0)<br \/> {cnt++;p\/=3;}<br \/> for(int i=5,j=25,k=4;j&lt;=p;i+=(k=6-k),j+=(i*2-k)*k)<br \/> {<br \/>  while(p%i==0)<br \/>  {cnt++;p\/=i;}  <br \/> }<br \/> if(p!=1)<br \/>  cnt+=2;<br \/> else<br \/>  cnt+=1;<br \/> return cnt;<br \/>}<br \/>int main()<br \/>{<br \/> int N,x,cnt=0;cin&gt;&gt;N;x=1;<br \/> while(x&lt;=N){cnt++;x*=2;} <br \/> cout&lt;&lt;cnt&lt;&lt;endl; <br \/> for(int i=1;i&lt;N;i++)<br \/>  cout&lt;&lt;num(i)&lt;&lt;&quot; &quot;;<br \/> cout&lt;&lt;num(N)&lt;&lt;endl;<br \/>} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u52a0\u4e86\u865a\u62df\u6bd4\u8d5b11\u9053\u53ea\u505a\u4e865\u9053\u3002\u3002SB\u963f\u3002\u3002346\u548c353\u90fd\u662f\u6a21\u62df\u7684\u9898\u76ee\u3002\u3002\u61d2\u5f97\u505a\u4e86\u3002\u3002347\u3002\u3002\u770b\u4ee3\u7801\u5427\u3002\u3002Code\u3002\u3002#include&lt;iostream&gt;#include&lt;string&gt;#include&lt;algorithm&gt;using namespace std;const int maxn=100+10;string A[maxn];bool cmp(const string&amp;A,const string&amp;B){return (A+B)&lt;(B+A);}int main(){int N;cin&gt;&gt;N;for(int i=0;i&lt;N;i++)cin&gt;&gt;A[i];sort(A,A+N,cmp);for(int i=0;i&lt;N;i++)cout&lt;&lt;A[i];cout&lt;&lt;endl;}350\u3002\u3002\u6709\u70b9\u610f\u601d\u7684\u9898\u76ee\u3002\u3002\u9996\u5148\u5982\u679c\u6709\u4e00\u4e2a\u89e3\u3002\u3002\u90a3\u4e48\u628a\u8fd9\u4e9b\u6570\u5168\u90e8xor\u4e0a\u4e00\u4e2a\u6570\u7684\u8bdd\u3002\u3002\u8fd8\u662f\u4e00\u4e2a\u89e3\u3002\u3002\u56e0\u4e3a(a xor x) xor (b xor x)=(a xor b) xor (x xor x)= a xor b xor 0= a xor b\u3002\u3002\u3002\u6240\u4ee5\u5c31\u5f53\u91cc\u9762\u6709\u4e00\u4e2a0\u597d\u4e86\u3002\u3002\u7136\u540e\u7279\u5224\u6389M\uff1d1\u7684\u60c5\u51b5\u3002\u3002\u90a3\u4e48\u6ce8\u610f\u5230\u3002\u3002\u5982\u679cB\u4e2d\u6709\u4e24\u4e2a\u6570A\u548cB\u3002\u3002A xor B\uff1d\u53e6\u4e00\u4e2a\u6570C\u3002\u3002\u90a3\u4e48A\u548cB\u5fc5\u7136\u6709\u516c\u5171\u7684\u5143\u7d20\u3002\u3002\u90a3\u4e48\u5c31\u5f88\u7b80\u5355\u4e86\u3002\u3002\u627e\u4e24\u4e2a\u6709\u516c\u5171\u5143\u7d20\u7684B\u4e2d\u7684\u6570i,j\u3002\u3002\u5f3a\u884c\u5c06\u5b83\u4eec\u7684\u516c\u5171\u5143\u7d20\u8bbe\u4e3a0\u3002\u3002\u90a3\u4e48\u73b0\u5728\u5c31\u67093\u4e2a\u6570\u4e860\uff0ci,j\u3002\u3002\u90a3\u4e48\u53ea\u8981\u627e\u5176\u4ed6\u7684\u67090\u7684\u5143\u7d20\u5c31\u53ef\u4ee5\u6c42\u51fa\u4e00\u4e2a\u89e3\u4e86\u3002\u3002\u600e\u4e48\u6c42\u627e\u5462\uff1f\u5982\u679cB\u4e2d\u6570x\u4e0d\u662fi xor j\u3002\u3002\u53c8\u8ddfi\u548cj\u90fd\u6709\u516c\u5171\u5143\u7d20\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u516c\u5171\u5143\u7d20\u53ea\u80fd\u662f0\u4e86\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u6570\u5c31\u5c5e\u4e8e\u89e3\u4e86\u3002\u3002\u3002\u5c31\u8fd9\u6837\u627e\u6570\u3002\u3002\u3002#include&lt;iostream&gt; #define REP(i,n) for(int i=0;i&lt;n;i++)using namespace std;const int maxn=100;int M,B[maxn];bool HaveCommon(int i,int j,int&amp;k){ int now=B[i]^B[j]; for(k=0;k&lt;M;k++) if(B[k]==now) return [&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\/24"}],"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=24"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}