锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品精品国产自在久久高清,久久99久久99精品免视看动漫,亚洲中文字幕无码久久2020http://www.shnenglu.com/yuziyu/姣忓ぉ榪涙涓鐐圭偣,Coding Everyday!zh-cnTue, 06 May 2025 23:07:20 GMTTue, 06 May 2025 23:07:20 GMT60[澶囧繕]鍑芥暟璋冪敤綰﹀畾http://www.shnenglu.com/yuziyu/archive/2009/07/23/90900.htmlYZYYZYThu, 23 Jul 2009 02:58:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/23/90900.htmlhttp://www.shnenglu.com/yuziyu/comments/90900.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/23/90900.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90900.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90900.htmlstdcall鏄痯ascal璇█鐨勯粯璁よ皟鐢ㄧ害瀹氾紝浠庡彸鍚戝乏鍘嬫爤錛岀敱琚皟鐢ㄨ呰礋璐f竻鏍?br />cdecl鏄痗璇█鐨勯粯璁よ皟鐢ㄧ害瀹氾紝浠庡彸鍚戝乏鍘嬫爤錛岀敱璋冪敤鑰呰礋璐f竻鏍堛?br />

YZY 2009-07-23 10:58 鍙戣〃璇勮
]]>
[鍩虹綆楁硶澶嶄範]鍩烘暟鎺掑簭http://www.shnenglu.com/yuziyu/archive/2009/07/17/90382.htmlYZYYZYFri, 17 Jul 2009 11:49:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90382.htmlhttp://www.shnenglu.com/yuziyu/comments/90382.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90382.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90382.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90382.html鍩烘暟鎺掑簭姣忎竴閬嶅寰呮帓鏁扮殑鏌愪竴浣嶈繘琛岃鏁版帓搴忥紝渚濇浠庢渶浣庝綅鍒版渶楂樹綅銆?br />涓嬮潰紼嬪簭鎶婇潪璐熸暟鎸?6榪涘埗澶勭悊錛屾瘡嬈″彇16榪涘埗鐨勪竴浣嶃傝繖鏍鋒瘮鐢?0榪涘埗鏂逛究蹇嵎寰堝銆?br />緙虹偣鏄笉鑳藉鐞嗚礋鏁般傚彲浠ュ皢鎵鏈夋暟閮藉鍔犱竴涓熀鏁版墍鍏舵垚涓烘鏁般傛帓搴忓畬鎴愬悗錛屽啀鍑忓幓榪欎釜鍩烘暟銆?br />浣嗘槸瀵逛簬32浣嶆渶灝忕殑璐熸暟1<<31榪欐牱涓涓壒渚嬶紝鏄笉琛岀殑銆?br />鐢ㄤ竴涓腑闂存暟緇勪繚瀛樹腑闂寸粨鏋滐紝姣忎竴閬嶆帓瀹屽悗錛屼氦鎹袱鎸囬拡錛岃繖鏍峰彲浠ラ伩鍏嶅嬈℃暟鎹鍒躲傜敱浜庝竴鍏辨湁8閬嶏紝緇撴潫鍚庯紝array涓負鏈鍚庝竴嬈℃帓瀹屽簭鐨勭粨鏋溿?br />
浠g爜濡備笅錛?br />
void聽_radix_sort(int*src,int*dst,int聽len,int聽offset);

int聽radix_sort(int*array,int聽begin,int聽end)
{
聽聽聽聽
if(array==NULL||begin>end)聽return0;

聽聽聽聽
int聽len聽=聽end-begin+1;
聽聽聽聽
int*tmp聽=聽malloc(sizeof(int)*len);

聽聽聽聽
int*src,*dst;

聽聽聽聽src聽
=聽array;
聽聽聽聽dst聽
=聽tmp;

聽聽聽聽
int聽i;
聽聽聽聽
for(i=0;i<32;i+=4){
聽聽聽聽聽聽聽聽_radix_sort(src,dst,len,i);
聽聽聽聽聽聽聽聽tmp聽
=聽src;
聽聽聽聽聽聽聽聽src聽
=聽dst;
聽聽聽聽聽聽聽聽dst聽
=聽tmp;
聽聽聽聽}

聽聽聽聽free(dst);

聽聽聽聽
return1;
}

void聽_radix_sort(int*src,int*dst,int聽len,int聽offset)
{
聽聽聽聽
int聽cnt[16];
聽聽聽聽memset(cnt,
0,sizeof(cnt));

聽聽聽聽
int聽mask聽=0xF<<offset;

聽聽聽聽
int聽i=0;
聽聽聽聽
for(i=0;i<len;++i){
聽聽聽聽聽聽聽聽cnt[聽(src[i]
&mask)>>offset聽]聽++;
聽聽聽聽}

聽聽聽聽
for(i=1;i<16;++i){
聽聽聽聽聽聽聽聽cnt[i]
+=cnt[i-1];
聽聽聽聽}

聽聽聽聽
for(i=len-1;i>=0;--i){
聽聽聽聽聽聽聽聽dst[
--cnt[(src[i]&mask)>>offset]]聽=聽src[i];聽
聽聽聽聽}
}





YZY 2009-07-17 19:49 鍙戣〃璇勮
]]>
[澶囧繕]'#'鍙風殑棰勫鐞?/title><link>http://www.shnenglu.com/yuziyu/archive/2009/07/17/90356.html</link><dc:creator>YZY</dc:creator><author>YZY</author><pubDate>Fri, 17 Jul 2009 08:55:00 GMT</pubDate><guid>http://www.shnenglu.com/yuziyu/archive/2009/07/17/90356.html</guid><wfw:comment>http://www.shnenglu.com/yuziyu/comments/90356.html</wfw:comment><comments>http://www.shnenglu.com/yuziyu/archive/2009/07/17/90356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/yuziyu/comments/commentRss/90356.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/yuziyu/services/trackbacks/90356.html</trackback:ping><description><![CDATA[ <br />#define macro(x) {#x,do_##x}<br />macro(hello)<br />棰勫鐞嗗悗灞曞紑涓?<br />{"hello",do_hello}<br /><br /><img src ="http://www.shnenglu.com/yuziyu/aggbug/90356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/yuziyu/" target="_blank">YZY</a> 2009-07-17 16:55 <a href="http://www.shnenglu.com/yuziyu/archive/2009/07/17/90356.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>USACO 4.1 Fence Loopshttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.htmlYZYYZYFri, 17 Jul 2009 06:26:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.htmlhttp://www.shnenglu.com/yuziyu/comments/90336.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90336.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90336.html闃呰鍏ㄦ枃

YZY 2009-07-17 14:26 鍙戣〃璇勮
]]>
[鍩虹綆楁硶澶嶄範]鍘熷湴緗崲鐨勯棿鎺ユ帓搴?/title><link>http://www.shnenglu.com/yuziyu/archive/2009/07/16/90212.html</link><dc:creator>YZY</dc:creator><author>YZY</author><pubDate>Thu, 16 Jul 2009 03:52:00 GMT</pubDate><guid>http://www.shnenglu.com/yuziyu/archive/2009/07/16/90212.html</guid><wfw:comment>http://www.shnenglu.com/yuziyu/comments/90212.html</wfw:comment><comments>http://www.shnenglu.com/yuziyu/archive/2009/07/16/90212.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/yuziyu/comments/commentRss/90212.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/yuziyu/services/trackbacks/90212.html</trackback:ping><description><![CDATA[瀵逛簬澶嶅埗浠d環寰堥珮鐨勫厓绱狅紝閫氳繃鏌愮鎺掑簭綆楁硶榪涜闂存帴鎺掑簭銆?br />鎺掑簭瀹屾垚鍚庯紝鍐嶄竴嬈″鍒跺洖鍘匯?br />榪欐牱闇瑕佷竴涓腑闂存暟緇勶紝榪涜2N嬈″鍒躲?br />閫氳繃鍘熷湴緗崲錛屾垜浠彲浠ュ彧浣跨敤涓涓腑闂村彉閲忥紝鏈澶氳繘琛?N/2嬈″鍒跺嵆鍙揪鍒扮洰鐨勩?br /><br />濡俰ndex[1]==3銆傞偅涔堬紝璇存槑array[1]榪欎釜浣嶇疆搴旇鏀劇殑鏄痑rray[3].鎴戜滑灝哸rray[1]淇濆瓨鍒皌mp涓?br />鐒跺悗array[1]=array[3].鐜板湪array[3]鏄彲浠ユ斁緗殑浜嗐傞偅涔堟垜浠湅array[3]搴旇鏀句粈涔堬紝濡傛灉index[3]==2,鍒氬ソ鎴戜滑鎶妕mp鏀懼洖鍘匯?br />涓嶇劧錛屾垜浠戶緇寜榪欎釜閾炬壘涓嬪幓銆?br />濡傛灉閾鵑暱涓簒.閭d箞鎴戜滑闇瑕亁+1嬈″鍒躲?br />閾鵑暱鏈灝忎負2.鎵浠ユ垜浠渶澶氬彧闇瑕?N/2嬈″鍒跺嵆鍙?br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽indirect_sort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽len)聽{<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(array</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">NULL</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">len</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">绱㈠紩鏁扮粍</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">index聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽malloc(</span><span style="color: rgb(0, 0, 255);">sizeof</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">(len));<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(index</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">NULL)聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j,largest,tmp,tmp2;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">len;</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽index[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i;<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鎻掑叆鎺掑簭</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">len;</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽index[i];<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(j</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">i;j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);">array[index[j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]]</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">array[tmp];</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">j){<br />聽聽聽聽聽聽聽聽聽聽聽聽index[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽index[j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽index[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">len;</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">濡傛灉index[i]==i錛岃鏄巃rray[i]宸茬粡鏀懼埌浜嗘渶緇堢殑鍦版柟銆?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(聽index[i]聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽i)<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">continue</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">{<br />聽聽聽聽聽聽聽聽聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[i];<br />聽聽聽聽聽聽聽聽聽聽聽聽j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i;<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(聽index[j]</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">i聽){<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">array[j]搴旇鏀劇殑鏄痑rray[index[j]]</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[index[j]];<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tmp2聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽j;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽index[j];<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍘熸潵鐨刟rray[j]宸茬粡鏀懼ソ浜?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽index[tmp2]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp2;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽聽聽聽聽聽聽聽聽index[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽j;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br />}<br /><br /></span></div><br /><img src ="http://www.shnenglu.com/yuziyu/aggbug/90212.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/yuziyu/" target="_blank">YZY</a> 2009-07-16 11:52 <a href="http://www.shnenglu.com/yuziyu/archive/2009/07/16/90212.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[鍩虹綆楁硶澶嶄範]Shell鎺掑簭http://www.shnenglu.com/yuziyu/archive/2009/07/16/90201.htmlYZYYZYThu, 16 Jul 2009 01:33:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/16/90201.htmlhttp://www.shnenglu.com/yuziyu/comments/90201.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/16/90201.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90201.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90201.htmlShell鎺掑簭浣跨敤涓涓掑搴忓垪h1,h2,h3...hk. h1==1銆?br />浠巋k寮濮嬶紝姣忔灝嗛棿闅攈x鐨勫簭鍒楁帓濂藉簭錛岀洿鍒癶1銆傞棿闅攈x鐨勫簭鍒楁帓濂藉簭鐨勬暟緇勫彲浠ョО涔嬩負hx鏈夊簭銆?br />Shell鎺掑簭鏈変竴涓噸瑕佺殑鎬ц川鏄竴涓猦x鏈夊簭鏁扮粍錛屽繀鐒舵槸涓涓猦x+1鏈夊簭鏁扮粍銆?br />姣忎竴閬嶆帓搴忚繃紼嬪彲浠ヤ嬌鐢ㄦ彃鍏ユ帓搴忋?br />
Shell鎺掑簭鐨勬ц兘鍙栧喅浜庨掑搴忓垪鐨勯夋嫨銆備笅闈唬鐮佺殑閫掑搴忓垪鏄痩en/2,len/4...,1.

int聽shell_sort(int*array,int聽begin,int聽end)
{
聽聽聽聽
if(array==NULL||begin>end)聽return0;

聽聽聽聽
int聽len聽=聽end-begin+1;

聽聽聽聽
int聽i,j,gap,tmp;
聽聽聽聽
for(gap=len/2;gap>=1;gap/=2){
聽聽聽聽聽聽聽
for(i=begin+gap;i<=end;++i){
聽聽聽聽聽聽聽聽聽聽聽j聽
=聽i;
聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽array[j];
聽聽聽聽聽聽聽聽聽聽聽
while(聽j-gap>=begin&&array[j-gap]>tmp聽){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽array[j]聽
=聽array[j-gap];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽j
-=gap;
聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽array[j]聽
=聽tmp;
聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
return1;
}




YZY 2009-07-16 09:33 鍙戣〃璇勮
]]>
[澶囧繕]鍐呭瓨瀵歸綈闂http://www.shnenglu.com/yuziyu/archive/2009/07/15/90145.htmlYZYYZYWed, 15 Jul 2009 08:37:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90145.htmlhttp://www.shnenglu.com/yuziyu/comments/90145.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90145.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90145.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90145.html鏄ㄥぉ鍜寃ub璁ㄨ錛屼負浠涔坰truct瀵歸綈鐨勬椂鍊欙紝double綾誨瀷鐨勫湴鍧瑕佷互8瀵歸綈銆?br />瀵歸綈鐨勭洰鐨勫氨鏄負浜嗘柟渚垮拰鍔犻熷鐞嗗櫒璇誨彇錛岄偅涔堝彧闇瑕佸拰瀛楅暱瀵歸綈灝卞彲浠ヤ簡銆?br />鏍規嵁榪欎袱綃囨枃绔狅細銆婂唴瀛樺榻愪笌ANSI C涓璼truct鍨嬫暟鎹殑鍐呭瓨甯冨眬銆?/font>vs銆婇毦浠ョ悊瑙g殑銆婂唴瀛樺榻愪笌ANSI C涓璼truct鍨嬫暟鎹殑鍐呭瓨甯冨眬銆?/a>銆?/a>gcc鍜寁c涓嬫槸涓嶅悓鐨勩?span style="font-size: 12pt; color: black;">瀵逛簬double綾誨瀷錛岄粯璁cc鐨?/span>瀵歸綈妯℃暟鏄?,VC鏄?.
鍐呭瓨瀵歸綈鏄笌澶勭悊鍣紝緙栬瘧鍣紝緙栬瘧閫夐」鐩稿叧鐨勶紝鍥犳鍗曠函緇欏嚭涓涓猻truct錛岄棶鍏秙izeof鏄灝戯紝榪欐牱鐨勯棶娉曟槸涓嶄弗璋ㄧ殑銆傚洖絳旇闂錛屽簲璇ュ姞浠ヨ鏄庤繍琛岀幆澧冦?br />vc鐨勯粯璁ゅ榻愭ā鏁版槸錛歴izeof(璇ョ被鍨?
gcc鐨勯粯璁ゅ榻愯鍒欐槸錛歜yte涓?,char涓?,鍏朵粬鍧囦負4.

鐢變笂鍙煡
struct s{
聽char c;
聽double d;
};

gcc涓?br />sizeof(s) = 4+8 錛?12
vc涓?br />sizeof(s) = 8+8 = 16

閭d箞 struct s{
double d;
char c;
};
璧峰垵鎴戣涓篶浠ュ悗涓嶉渶瑕佸~鍏咃紝鍥犳gcc涓媠izeof(s)=8+1 = 9銆備絾浜嬪疄搴旇鏄痵izeof(s)==8+4 = 12銆?br />鍥犱負瀵逛簬鏁扮粍鏉ヨ錛岃淇濊瘉鏁扮粍鐨勫ぇ灝忕瓑浜庢暟緇勭殑涓暟涔樹互鍏冪礌鐨勫ぇ灝忋傚洜姝涔嬪悗涔熸槸闇瑕佸~鍏呯殑,榪欐牱鍚庣畫鐨勫厓绱犵殑鍦板潃鎵嶄細鏄瓧闀跨殑鍊嶆暟銆?br />


YZY 2009-07-15 16:37 鍙戣〃璇勮
]]>
[鍩虹綆楁硶澶嶄範]鍐掓場鎺掑簭鍜岄夋嫨鎺掑簭http://www.shnenglu.com/yuziyu/archive/2009/07/15/90126.htmlYZYYZYWed, 15 Jul 2009 03:59:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90126.htmlhttp://www.shnenglu.com/yuziyu/comments/90126.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90126.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90126.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90126.html
鍐掓場鎺掑簭錛?br />
int聽bubble_sort(int*array,int聽begin,int聽end)
{
聽聽聽聽
if(array==NULL||begin>end)聽return0;

聽聽聽聽
int聽i,j;

聽聽聽聽
for(i=end;i>begin;--i){
聽聽聽聽聽聽聽聽
for(j=begin;j<i;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
if(聽array[j]>array[j+1]聽){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽tmp聽=聽array[j];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽array[j]聽
=聽array[j+1];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽array[j
+1]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
return1;
}

閫夋嫨鎺掑簭錛?br />
int聽select_sort(int*array,int聽begin,int聽end)聽{

聽聽聽聽
if(array==NULL||begin>end)聽return0;

聽聽聽聽
int聽i,j,largest,tmp;

聽聽聽聽
for(i=end;i>begin;--i){

聽聽聽聽聽聽聽聽largest聽
=聽i;
聽聽聽聽聽聽聽聽
for(j=begin;j<=i;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
if(聽array[largest]<array[j]聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽largest聽
=聽j;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽tmp聽
=聽array[i];
聽聽聽聽聽聽聽聽array[i]聽
=聽array[largest];
聽聽聽聽聽聽聽聽array[largest]聽
=聽tmp;
聽聽聽聽}

聽聽聽聽
return1;
}




YZY 2009-07-15 11:59 鍙戣〃璇勮
]]>
[鍩虹綆楁硶澶嶄範]褰掑茍鎺掑簭http://www.shnenglu.com/yuziyu/archive/2009/07/15/90122.htmlYZYYZYWed, 15 Jul 2009 03:46:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90122.htmlhttp://www.shnenglu.com/yuziyu/comments/90122.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/15/90122.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90122.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90122.html
static void 聽_merge( int * src, int 聽begin, int 聽end);

int 聽merge_sort( int * array, int 聽begin, int 聽end)
{
聽聽聽聽
if (array == NULL || begin > end)聽 return 0 ;

聽聽聽
int 聽mid聽 = 聽begin + (end - begin) / 2 ;
聽聽 merge_sort(src,begin,mid);
聽聽 merge_sort(src,mid
+ 1 ,end);
聽聽聽_merge(src,begin,end);

聽聽聽 return 1;
}

static void 聽_merge( int * src, int 聽begin, int 聽end)
{
聽聽聽聽
int 聽mid聽 = 聽begin + (end - begin) / 2 ;

聽聽聽聽
int 聽b1聽 = 聽begin;
聽聽聽聽
int 聽e1聽 = 聽mid;
聽聽聽聽
int 聽b2聽 = 聽mid + 1 ;
聽聽聽聽
int 聽e2聽 = 聽end;

聽聽聽聽
int * dest聽 = 聽malloc( sizeof ( int ) * (end - begin + 1 ));
聽聽聽聽
if (dest == NULL)聽 return ;

聽聽聽聽
int 聽i1;
聽聽聽聽
int 聽i2;
聽聽聽聽
int 聽i;
聽聽聽聽
for (i1 = b1,i2 = b2,i = begin;i1 <= e1 && i2 <= e2 && i <= end; ++ i){
聽聽聽聽聽聽聽聽
if (src[i1] < src[i2]){
聽聽聽聽聽聽聽聽聽聽聽聽dest[i
- begin]聽 = 聽src[i1];
聽聽聽聽聽聽聽聽聽聽聽聽i1
++ ;
聽聽聽聽聽聽聽聽}
else {
聽聽聽聽聽聽聽聽聽聽聽聽dest[i
- begin]聽 = 聽src[i2];
聽聽聽聽聽聽聽聽聽聽聽聽i2
++ ;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
for (;i <= end && i1 <= e1; ++ i, ++ i1)
聽聽聽聽聽聽聽dest[i
- begin]聽 = 聽src[i1];
聽聽聽聽
for (;i <= end && i2 <= e2; ++ i, ++ i2)
聽聽聽聽聽聽聽dest[i
- begin]聽 = 聽src[i2];

聽聽聽聽
for (i = begin;i <= end; ++ i)
聽聽聽聽聽聽聽聽src[i]聽
= 聽dest[i - begin];

聽聽聽聽free(dest);
}


鍋氫竴浜涘皬浼樺寲錛屽彧鍒涘緩涓嬈′復鏃舵暟緇勩?br />
void聽_mergesort(int*array,int*tmp,int聽start,int聽end);

void聽mergesort(int*array,int聽len)
{
聽聽聽聽
int聽i,*tmp;

聽聽聽聽
if(array==NULL||len==0)
聽聽聽聽聽聽聽聽
return;

聽聽聽聽tmp聽
=聽(int*)malloc(sizeof(int)*len);

聽聽聽聽_mergesort(array,tmp,
0,len-1);

聽聽聽 free(tmp);
}

void聽_mergesort(int*array,int*tmp,int聽start,int聽end)
{
聽聽聽聽
int聽mid聽=聽(start+end)/2;
聽聽聽聽
int聽i,j,k;

聽聽聽聽
if(start>=end)
聽聽聽聽聽聽聽聽
return;
聽聽聽聽
聽聽聽聽_mergesort(array,tmp,start,mid);
聽聽聽聽_mergesort(array,tmp,mid
+1,end);

聽聽聽i聽
=聽start;
聽聽聽j聽
=聽mid+1;

聽聽聽
for(k=start;k<=end&&i<=mid&&j<=end;++k){
聽聽聽聽聽聽聽
if(array[i]<array[j]){
聽聽聽聽聽聽聽聽聽聽聽tmp[k]聽
=聽array[i];
聽聽聽聽聽聽聽聽聽聽聽i
++;
聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽tmp[k]
=聽array[j];
聽聽聽聽聽聽聽聽聽聽聽j
++;
聽聽聽聽聽聽聽}
聽聽聽}

聽聽聽
for(;i<=mid;++i)
聽聽聽聽聽聽聽tmp[k
++]=array[i];

聽聽聽
for(;j<=end;++j)
聽聽聽聽聽聽聽tmp[k
++]=array[j];
聽聽聽聽聽聽
聽聽memcpy(
&array[start],&tmp[start],sizeof(int)*(end-start+1));聽
}
聽聽聽



YZY 2009-07-15 11:46 鍙戣〃璇勮
]]>
[鍩虹綆楁硶澶嶄範]鍫嗘帓搴?/title><link>http://www.shnenglu.com/yuziyu/archive/2009/07/15/90109.html</link><dc:creator>YZY</dc:creator><author>YZY</author><pubDate>Wed, 15 Jul 2009 01:50:00 GMT</pubDate><guid>http://www.shnenglu.com/yuziyu/archive/2009/07/15/90109.html</guid><wfw:comment>http://www.shnenglu.com/yuziyu/comments/90109.html</wfw:comment><comments>http://www.shnenglu.com/yuziyu/archive/2009/07/15/90109.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/yuziyu/comments/commentRss/90109.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/yuziyu/services/trackbacks/90109.html</trackback:ping><description><![CDATA[ <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);">static</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">void</span> <span style="color: rgb(0, 0, 0);">聽_build_heap(</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">array,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽len);<br /></span> <span style="color: rgb(0, 0, 255);">static</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">void</span> <span style="color: rgb(0, 0, 0);">聽_adjust_heap(</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">array,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽idx,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽len);<br /><br /></span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽heap_sort(</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">array,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽begin,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(array</span> <span style="color: rgb(0, 0, 0);">==</span> <span style="color: rgb(0, 0, 0);">NULL</span> <span style="color: rgb(0, 0, 0);">||</span> <span style="color: rgb(0, 0, 0);">begin</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);">end)聽</span> <span style="color: rgb(0, 0, 255);">return</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">0</span> <span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">鑷浠ュ悗錛宨ndex浠?寮濮嬨?/span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);">聽聽聽聽array</span> <span style="color: rgb(0, 0, 0);">--</span> <span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽len聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽end</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">begin</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽_build_heap(array,len);<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽i;<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">for</span> <span style="color: rgb(0, 0, 0);">(i</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">;i</span> <span style="color: rgb(0, 0, 0);"><</span> <span style="color: rgb(0, 0, 0);">len;</span> <span style="color: rgb(0, 0, 0);">++</span> <span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽tmp聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽array[len</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">i</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽聽聽聽聽array[len</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">i</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">]聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽array[</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽聽聽聽聽array[</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">]聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽聽聽聽聽_adjust_heap(array,</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">,len</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">i);<br />聽聽聽聽}<br />}<br /><br /></span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">input:聽浠繪剰鏁扮粍聽output:澶ч《鍫?/span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 255);">static</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">void</span> <span style="color: rgb(0, 0, 0);">聽_build_heap(</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">array,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽len)<br />{<br />聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽i;<br />聽聽聽</span> <span style="color: rgb(0, 0, 255);">for</span> <span style="color: rgb(0, 0, 0);">(i</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">len</span> <span style="color: rgb(0, 0, 0);">/</span> <span style="color: rgb(0, 0, 0);">2</span> <span style="color: rgb(0, 0, 0);">;i</span> <span style="color: rgb(0, 0, 0);">>=</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">;</span> <span style="color: rgb(0, 0, 0);">--</span> <span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽_adjust_heap(array,i,len);<br />聽聽聽}<br />}<br /><br /></span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">浣塊噸鏂頒嬌array婊¤凍鍫嗙壒鎬?/span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 255);">static</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">void</span> <span style="color: rgb(0, 0, 0);">聽_adjust_heap(</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">array,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽idx,</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽len)<br />{<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽left;<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽right;<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽larger聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽idx;<br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">int</span> <span style="color: rgb(0, 0, 0);">聽tmp聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽array[idx];<br /><br />聽聽聽聽left聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽(idx</span> <span style="color: rgb(0, 0, 0);"><<</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽right聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽left</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">while</span> <span style="color: rgb(0, 0, 0);">(聽left</span> <span style="color: rgb(0, 0, 0);"><=</span> <span style="color: rgb(0, 0, 0);">聽len){<br />聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(right</span> <span style="color: rgb(0, 0, 0);"><=</span> <span style="color: rgb(0, 0, 0);">len</span> <span style="color: rgb(0, 0, 0);">&&</span> <span style="color: rgb(0, 0, 0);">array[right]</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);">array[left]){<br />聽聽聽聽聽聽聽聽聽聽聽聽larger聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽right;聽<br />聽聽聽聽聽聽聽聽}</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">{<br />聽聽聽聽聽聽聽聽聽聽聽聽larger聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽left;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">(聽array[larger]</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);">tmp聽){<br />聽聽聽聽聽聽聽聽聽聽聽聽array[idx]聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽array[larger];<br />聽聽聽聽聽聽聽聽聽聽聽聽idx聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽larger;<br />聽聽聽聽聽聽聽聽聽聽聽聽left聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽(idx</span> <span style="color: rgb(0, 0, 0);"><<</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽聽聽聽聽聽聽right聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽left</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">break</span> <span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽array[idx]聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽tmp;<br />}<br /><br /></span> </div> <br /> <img src ="http://www.shnenglu.com/yuziyu/aggbug/90109.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/yuziyu/" target="_blank">YZY</a> 2009-07-15 09:50 <a href="http://www.shnenglu.com/yuziyu/archive/2009/07/15/90109.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[鍩虹綆楁硶澶嶄範]蹇熸帓搴?/title><link>http://www.shnenglu.com/yuziyu/archive/2009/07/14/90079.html</link><dc:creator>YZY</dc:creator><author>YZY</author><pubDate>Tue, 14 Jul 2009 13:58:00 GMT</pubDate><guid>http://www.shnenglu.com/yuziyu/archive/2009/07/14/90079.html</guid><wfw:comment>http://www.shnenglu.com/yuziyu/comments/90079.html</wfw:comment><comments>http://www.shnenglu.com/yuziyu/archive/2009/07/14/90079.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/yuziyu/comments/commentRss/90079.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/yuziyu/services/trackbacks/90079.html</trackback:ping><description><![CDATA[鏈鍩虹鐨勫揩閫熸帓搴?br />浼樼偣錛氱紪鐮佺畝鍗曪紝娓呮櫚<br />緙虹偣錛氬浜庢帓濂藉簭鐨勮緭鍏ワ紝鏃墮棿澶嶆潅搴︿負O(n^2)<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽partition(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽start,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end);<br /><br /></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽quicksort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽start,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(array</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">NULL</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">start</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">end)聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽t聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽partition(array,start,end);<br /><br />聽聽聽聽quicksort(array,start,t</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽quicksort(array,t</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,end);<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽partition(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽start,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽pivot聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[start];聽聽聽聽<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽start;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽end;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(聽i</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">j聽){<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"> j</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">&& array[j]</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">pivot</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">)聽j</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽array[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[j];<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">( j>i&& array[i]</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">pivot</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"> )聽i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[i];<br />聽聽聽聽}<br /><br />聽聽聽聽array[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽pivot;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽i;<br />}<br /><br /></span></div><br />鏀硅繘錛氬皬鏁扮粍鐩存帴鐢ㄦ彃鍏ユ帓搴忓疄鐜幫紝涓灑鍊煎彇(begin,mid,end)涓夎呯殑涓棿鍊鹼紝瀵規湁搴忔暟緇勬帓搴忎粛涓篛(nlogn)銆傚噺灝戜簡杈圭晫鏉′歡媯鏌?br />緙虹偣錛氱紪鐮佸鏉傘?br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">#include聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">stdio.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br />#include聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">stdlib.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br />#include聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">memory.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽SMALL_N聽10</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽partition(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽begin,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end);<br /><br /></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽_quicksort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽begin,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end);<br /><br /></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽insertsort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽len)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(array</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">NULL</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">len</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">len;</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i){<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽temp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[i];<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽j;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(j</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">i;j</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);">temp</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">array[j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">j){<br />聽聽聽聽聽聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽temp;<br />聽聽聽聽}<br /><br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽quicksort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽len)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(array</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">NULL</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">len</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽_quicksort(array,</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,len</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />}<br /><br /><br /></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽_quicksort(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽begin,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽pivot;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽pivot_pos;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">begin</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">SMALL_N){<br />聽聽聽聽聽聽聽聽insertsort(</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">array[begin],end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">begin</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽}<br /><br />聽聽聽聽pivot_pos聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽partition(array,begin,end);<br />聽聽聽聽_quicksort(array,begin,pivot_pos</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽_quicksort(array,pivot_pos</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,end);<br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽聽mid3(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽begin,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽mid聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">begin)</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">begin;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽tmp;<br /><br />聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[mid];<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(tmp</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">array[begin]){<br />聽聽聽聽聽聽聽聽array[mid]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[begin];<br />聽聽聽聽聽聽聽聽array[begin]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽}<br /><br />聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[end];<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(tmp</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">array[mid]){<br />聽聽聽聽聽聽聽聽array[end]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[mid];<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(tmp</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">array[begin]){<br />聽聽聽聽聽聽聽聽聽聽聽array[mid]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[begin];<br />聽聽聽聽聽聽聽聽聽聽聽array[begin]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">{<br />聽聽聽聽聽聽聽聽聽聽聽聽array[mid]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽array[end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[mid];<br />聽聽聽聽array[mid]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽array[end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br />}<br /><br /><br /></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽partition(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">array,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽begin,</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽end)<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽pivot聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽mid3(array,begin,end);<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,聽j;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽tmp;<br /><br />聽聽聽聽i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽begin;<br />聽聽聽聽j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">){<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(array[</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">i]</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">pivot)聽;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">(array[</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">j]</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">pivot)聽;<br />聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(i</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">j)<br />聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[j];<br />聽聽聽聽聽聽聽array[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[i];<br />聽聽聽聽聽聽聽array[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽}<br /><br />聽聽聽聽tmp聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[i];<br />聽聽聽聽array[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽array[end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br />聽聽聽聽array[end</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽tmp;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽i;<br />}<br /><br /></span></div><br /><br /><br /><br /><br /><img src ="http://www.shnenglu.com/yuziyu/aggbug/90079.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/yuziyu/" target="_blank">YZY</a> 2009-07-14 21:58 <a href="http://www.shnenglu.com/yuziyu/archive/2009/07/14/90079.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>錛誨蹇橈冀灝佽printfhttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89890.htmlYZYYZYSun, 12 Jul 2009 13:07:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89890.htmlhttp://www.shnenglu.com/yuziyu/comments/89890.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89890.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89890.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89890.html
void聽my_trace(constchar*cmd,)
{
聽聽聽聽va_list聽args;

聽聽聽聽va_start(args,cmd);
聽聽聽聽vprintf(cmd,args); //蹇呴』鐢╲printf
聽聽聽聽va_end(args);
}




YZY 2009-07-12 21:07 鍙戣〃璇勮
]]>
USACO 4.1 Beef McNuggetshttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.htmlYZYYZYSun, 12 Jul 2009 06:58:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.htmlhttp://www.shnenglu.com/yuziyu/comments/89864.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89864.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89864.html鍏堝皢box榪涜鎺掑簭銆?br />濡傛灉box閲岄潰鐨勬暟鐨勬渶澶у叕綰︽暟涓嶄負1鐨勮瘽錛岄偅涔堟墍鏈夌粍鎴愮殑鏁幫紝鍙彲鑳芥槸榪欎釜鍏害鏁扮殑鍊嶆暟錛屽洜姝ゆ病鏈変笂闄愶紝杈撳嚭涓?.
鐢╨ast璁板綍鏈灝忕殑鈥滀笉鑳界粍鎴愮殑鏁扳濄傝繖鏍峰綋last涔嬪悗鏈塨oxs[0]涓繛緇暟閮藉彲浠ョ粍鎴愮殑璇濓紝閭d箞鎵鏈夌殑鏁伴兘鍙互緇勬垚銆?br />last+1...last+box[0]鍙互緇勬垚鐨勮瘽錛岄偅涔堟瘡涓暟閮藉姞涓涓猙ox[0],閭d箞鏂頒竴杞殑box[0]涓暟涔熷彲浠ョ粍鎴愶紝浠ユ綾繪帹銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"nuggets.in");
ofstream聽fout(
"nuggets.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽box_num;
int聽boxs[10];

bool聽ok[256];

int聽gcd(int聽a,int聽b)
{
聽聽聽聽
if(a<b)聽swap(a,b);

聽聽聽聽
int聽tmp;

聽聽聽聽
while(b!=0){
聽聽聽聽聽聽聽聽tmp聽
=聽a;
聽聽聽聽聽聽聽聽a聽
=聽b;
聽聽聽聽聽聽聽聽b聽
=聽tmp%b;
聽聽聽聽}

聽聽聽聽
return聽a;
}

void聽solve()
{

聽聽聽聽
in>>box_num;
聽聽聽聽
for(int聽i=0;i<box_num;++i)
聽聽聽聽聽聽聽聽
in>>boxs[i];

聽聽聽聽sort(
&boxs[0],&boxs[box_num]);
聽聽聽聽
聽聽聽聽
int聽t聽=聽boxs[0];

聽聽聽聽
for(int聽i=1;i<box_num;++i){
聽聽聽聽聽聽聽聽t聽
=聽gcd(t,boxs[i]);
聽聽聽聽}

聽聽聽聽
if(t!=1){
聽聽聽聽聽聽聽聽
out<<0<<endl;
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}

聽聽聽聽memset(ok,
0,sizeof(ok));

聽聽聽聽
int聽last聽=0;
聽聽聽聽ok[
0]聽=true;
聽聽聽聽
int聽i=0;

聽聽聽聽
while(true){
聽聽聽聽聽聽聽聽
if(ok[i%256]){
聽聽聽聽聽聽聽聽聽聽聽聽ok[i
%256]聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
if(i-last>=boxs[0]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<last<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽x=0;x<box_num;++x){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ok[(i
+boxs[x])%256]聽=true;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽last聽
=聽i;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
++i;
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}


Beef McNuggets

Hubert Chen

Farmer Brown's cows are up in arms, having heard that McDonalds is considering the introduction of a new product: Beef McNuggets. The cows are trying to find any possible way to put such a product in a negative light.

One strategy the cows are pursuing is that of `inferior packaging'. ``Look,'' say the cows, ``if you have Beef McNuggets in boxes of 3, 6, and 10, you can not satisfy a customer who wants 1, 2, 4, 5, 7, 8, 11, 14, or 17 McNuggets. Bad packaging: bad product.''

Help the cows. Given N (the number of packaging options, 1 <= N <= 10), and a set of N positive integers (1 <= i <= 256) that represent the number of nuggets in the various packages, output the largest number of nuggets that can not be purchased by buying nuggets in the given sizes. Print 0 if all possible purchases can be made or if there is no bound to the largest number.

The largest impossible number (if it exists) will be no larger than 2,000,000,000.

PROGRAM NAME: nuggets

INPUT FORMAT

Line 1: N, the number of packaging options
Line 2..N+1: The number of nuggets in one kind of box

SAMPLE INPUT (file nuggets.in)

3
3
6
10

OUTPUT FORMAT

The output file should contain a single line containing a single integer that represents the largest number of nuggets that can not be represented or 0 if all possible purchases can be made or if there is no bound to the largest number.

SAMPLE OUTPUT (file nuggets.out)

17


YZY 2009-07-12 14:58 鍙戣〃璇勮
]]>
USACO 3.4 Raucous Rockershttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.htmlYZYYZYSat, 11 Jul 2009 03:48:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.htmlhttp://www.shnenglu.com/yuziyu/comments/89781.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89781.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89781.html涓寮濮嬫妸棰樻剰鐞嗚В閿欎簡錛屼互涓哄埢鍦ㄥ悓涓寮犲厜鐩樹笂鐨勬瓕鏇茬殑鏃墮棿欏哄簭涓嶅彉灝卞彲浠ヤ簡銆?br />浜嬪疄涓婁笉浠呭悓鍏夌洏涓婄殑姝屾洸鍐欏叆鏃墮棿瑕佹寜欏哄簭錛屽墠涓寮犲厜鐩樹笂鐨勬瓕鏇蹭笉鑳芥瘮鍚庝竴寮犳瓕鏇插啓鍏ユ椂闂磋鏅氥?br />
鏁版嵁閲忔瘮杈冨皯錛岀敤鍥炴函娉曪紝dp涔熻銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"rockers.in");
ofstream聽fout(
"rockers.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽capacity[20];;
int聽songs[20];
int聽song_num,disk_num;

int聽res聽=0;
int聽cur;

void聽backtracing(int聽depth,int聽last)
{
聽聽聽聽
if(depth==song_num){
聽聽聽聽聽聽聽聽
if(cur>res){
聽聽聽聽聽聽聽聽聽聽聽聽res聽
=聽cur;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}
聽聽聽
聽聽聽 //濡傛灉鍚庨潰鎵鏈夌殑姝屾洸閮藉姞涓婅繕姣旀渶浼樺煎皬錛屽壀鏋?br />聽聽聽聽
if(cur+song_num-depth<=res)
聽聽聽聽聽聽聽
return;聽

聽聽聽聽
for(int聽i=last;i<disk_num;++i){
聽聽聽聽聽聽聽聽 //濡傛灉褰撳墠姝屾洸闇瑕佸埢褰曪紝閭e彧闇鍒誨湪絎竴寮犺兘瑁呭緱涓嬬殑鍏夌洏涓娿?br />聽聽聽聽聽聽聽聽
if(聽capacity[i]>=songs[depth]){
聽聽聽聽聽聽聽聽聽聽聽聽cur
++;
聽聽聽聽聽聽聽聽聽聽聽聽capacity[i]
-=songs[depth];
聽聽聽聽聽聽聽聽聽聽聽聽backtracing(depth
+1,i);
聽聽聽聽聽聽聽聽聽聽聽聽capacity[i]
+=songs[depth];
聽聽聽聽聽聽聽聽聽聽聽聽cur
--;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽 // 涓嶅埢褰撳墠姝屾洸
聽聽聽聽backtracing(depth
+1,last);

}

void聽solve()
{
聽聽聽聽
int聽c;
聽聽聽聽
in>>song_num>>c>>disk_num;

聽聽聽聽
for(int聽i=0;i<song_num;++i)
聽聽聽聽聽聽聽聽
in>>songs[i];

聽聽聽聽
for(int聽i=0;i<disk_num;++i)
聽聽聽聽聽聽聽聽capacity[i]聽
=聽c;

聽聽聽聽backtracing(
0,0);

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-11 11:48 鍙戣〃璇勮
]]>
USACO 3.4 Electric Fencehttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.htmlYZYYZYFri, 10 Jul 2009 14:19:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.htmlhttp://www.shnenglu.com/yuziyu/comments/89761.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89761.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89761.html
#include聽<iostream>
#include聽
<fstream>
#include聽
<cmath>

usingnamespace聽std;

ifstream聽fin(
"fence9.in");
ofstream聽fout(
"fence9.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

void聽solve()
{
聽聽聽聽
int聽n,m,p;
聽聽聽聽
in>>n>>m>>p;

聽聽聽聽
int聽res聽=0;

聽聽聽聽
int聽s,e;
聽聽聽聽
for(int聽y=1;y<m;++y){
聽聽聽聽聽聽聽聽s聽
=聽n*y/m+1;
聽聽聽聽聽聽聽聽e聽
=聽(聽y*(n-p)%m==0聽)聽?聽(y*(n-p)/m-1+p)聽:聽floor(((double)y*(n-p)/m)+p);
聽聽聽聽聽聽
//聽聽out<<y<<"聽"<<s<<"聽"<<e<<endl;
聽聽聽聽聽聽聽聽res聽+=聽max(0,(e-s+1));
聽聽聽聽}

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-07-10 22:19 鍙戣〃璇勮
]]>
USACO 3.4 American Heritagehttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.htmlYZYYZYFri, 10 Jul 2009 10:51:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.htmlhttp://www.shnenglu.com/yuziyu/comments/89748.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89748.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89748.html闃呰鍏ㄦ枃

YZY 2009-07-10 18:51 鍙戣〃璇勮
]]>
USACO 3.3 A Gamehttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.htmlYZYYZYThu, 09 Jul 2009 05:50:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.htmlhttp://www.shnenglu.com/yuziyu/comments/89638.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89638.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89638.html鍔ㄦ佽鍒掓硶銆?br />鐢╠p[player][start][end]琛ㄧずplayer鍦╗start..end]浼氬彇寰楃殑鏈澶у箋?br />濡傛灉player==0錛岄偅涔坧layer鏈変富鍔ㄦ潈錛屽畠瑕佷箞閫塻tart,瑕佷箞閫塭nd.鏄劇劧錛屽畠瑕侀変嬌寰楀鎵嬪緱鍒嗘渶灝戠殑閭d竴涓?br />褰撳畠閫塻tart鏃訛紝瀵規墜鎵鑳藉埌鐨勬渶澶у間負dp[1][start+1][end]銆傚綋瀹冮塭nd鏃訛紝瀵規墜鎵閫夌殑鏈澶у兼槸dp[1][start][end-1].
銆傛墍浠ユ垜浠塪p[1][start+1][end]鍜宒p[1][start][end-1]涓皬鐨勯偅涓涓?br />濡傛灉player==1錛岄偅鍙兘琚姩鐨勭瓑0鍏堥変簡銆?鍦ㄥ墿涓嬪尯孌典腑錛屽張浣滀負鍏堥夌殑瑙掕壊錛屽嵆player0銆?br />褰撳彧鏈変竴涓暟瀛楃殑鏃跺欙紝player0灝卞彧鏈夐夎繖涓紝player1灝辨病寰楅夛紝榪斿洖0.
浠g爜濡備笅錛?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"game1.in");
ofstream聽fout(
"game1.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽dp[2][100][100];
int聽sequence[100];

int聽score(int聽player,int聽start,int聽end)
{
聽聽聽聽
if(dp[player][start][end]!=-1)
聽聽聽聽聽聽聽聽
return聽dp[player][start][end];

聽聽聽聽
if(start==end){
聽聽聽聽聽聽聽聽
if(player==0)
聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[start];
聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=0;
聽聽聽聽}
else{
聽聽聽聽聽聽聽聽
int聽t1聽=聽score(0,start+1,end);
聽聽聽聽聽聽聽聽
int聽t2聽=聽score(0,start,end-1);
聽聽聽聽聽聽聽聽
if(player==0){
聽聽聽聽聽聽聽聽聽聽聽聽
if(t1>t2){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[end]+score(1,start,end-1);
聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[start]+score(1,start+1,end);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽
if(t1>t2){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽score(0,start,end-1);
聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽score(0,start+1,end);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
return聽dp[player][start][end];
}

void聽solve()
{
聽聽聽聽memset(dp,
-1,sizeof(dp));

聽聽聽聽
int聽size;
聽聽聽聽
in>>size;

聽聽聽聽
for(int聽i=0;i<size;++i)
聽聽聽聽聽聽聽聽
in>>sequence[i];

聽聽聽聽
out<<score(0,0,size-1)<<""<<score(1,0,size-1)<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-09 13:50 鍙戣〃璇勮
]]>
SRM 444http://www.shnenglu.com/yuziyu/archive/2009/07/08/89565.htmlYZYYZYWed, 08 Jul 2009 13:29:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89565.htmlhttp://www.shnenglu.com/yuziyu/comments/89565.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89565.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89565.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89565.html絎簩棰橈紝涓鐪嬫尯綆鍗曪紝灝辨槸姹傝川鍥犳暟鐨勪釜鏁幫紝鐒跺悗鐪嬭兘琚?鐨勫嚑嬈″箓鏁撮櫎銆?br />涓寮濮嬪寙蹇欏啓浜嗕竴涓紝鐒跺悗鎻愪氦錛?00鍒嗐?br />浠g爜濡備笅錛?br />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽int聽getLevel(longlong聽N)聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽res聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(longlong聽i=2;i*i<=N;++i){聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(N%i==0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽N
/=i;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽r=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(res/4!=0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
/=4;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽r
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽r;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽
鍚庢潵涓鐪嬶紝i*i<=N榪欐椂錛孨涓鐩村湪鍙橈紝搴旇淇濆瓨涓婲鎴栬呯洿鎺ユ眰sqrt(N)銆備竴寮濮嬩笉澶‘瀹歴qrt鑳藉惁澶勭悊long long錛屽洜姝ょ敤鐩鎬箻鐨勬柟娉曘傚悗鏉ha浜虹殑鏃跺欙紝鍙戠幇涓涓篃鐘簡鍚屾牱鐨勯敊璇紝椹笂鏋勯?6=2*2*2*7,cha鎺?br />浜庢槸鏀規垚涓嬮潰錛屾彁浜わ紝鍙湁299鍒嗕簡銆傘傘?br />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽int聽getLevel(longlong聽N)聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽res聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
longlong聽T聽=聽N;聽//澧炲姞榪欎竴琛屄犅犅犅犅犅犅犅犅犅犅犅?/span>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽for(longlong聽i=2;i*i<=T;++i){聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(N%i==0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽N
/=i;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽r=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(res/4!=0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
/=4;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽r
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽r;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽

緇撴灉榪樻槸琚玞ha鎺変簡銆傚洜涓虹姱浜嗕竴涓弗閲嶇殑閿欒錛屾病鏈夌畻涓婃渶鍚庝竴涓川鍥犳暟錛岃繖涓川鍥犳暟鍙兘澶т簬sqrt(N)銆傚88==2*2*2*11銆?br />姝g‘浠g爜搴旇鏄?br />
聽聽聽聽聽聽聽聽聽聽聽聽聽聽int聽getLevel(longlong聽N)聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽res聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
longlong聽T聽=聽N;聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(longlong聽i=2;i*i<=T;++i){聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(N%i==0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽N
/=i;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(N!=1)聽res++;聽//澧炲姞榪欎竴琛?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽int聽r=0;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
while(res/4!=0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽res
/=4;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽r
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽r;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽

鏈鍚庢埧闂村彧鏈変竴浜鴻繃浜嗙浜岄銆?br />榪樺ソcha浜?涓紝涓嶇劧rating瑕佽穼涓嶅皯浜嗐傘?br />榪樺ソrating榪樻槸娑ㄤ簡涓鐐圭偣銆傘?br />澶矖蹇冧簡錛屼笉鐒跺氨搴旇鑳借繘div1浜嗐傘?br />


YZY 2009-07-08 21:29 鍙戣〃璇勮
]]>
USACO 3.3 Home on the Rangehttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.htmlYZYYZYWed, 08 Jul 2009 09:44:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.htmlhttp://www.shnenglu.com/yuziyu/comments/89557.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89557.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89557.html濡傛灉dp[i][j][m]瀹屾暣錛屽垯褰撲笖浠呭綋dp[i][j][m-1],dp[i+1][j][m-1],dp[i][j+1][m-1],dp[i+1][j+1][m-1]鐨勬鏂瑰艦涔熸槸瀹屾暣鐨?鐢諱釜鍥懼氨寰堟竻鏅頒簡)銆傜敱浜庢垜浠粠涓婂埌涓嬶紝浠庡乏鍒板彸鎵弿姣忎釜鐐癸紝鍦ㄦ瘡涓杞甶,j鐢ㄨ繃涓嬈★紝灝變笉浼氬啀浣跨敤錛屾墍浠ュ彧闇鐢ㄤ簩緇存暟緇勪繚瀛榙p[i][j]錛屽嵆鍙?br />鏃墮棿澶嶆潅搴︿負O(n^3),絀洪棿澶嶆潅搴︿負O(n^2)銆俛nalysis涓湁涓椂闂村鏉傚害涓篛(n^2),絀洪棿O(n)鐨勮В娉曘?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"range.in");
ofstream聽fout(
"range.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

bool聽dp[250][250];
int聽side_len;

void聽input()
{
聽聽聽聽
in>>side_len;

聽聽聽聽
char聽t;

聽聽聽聽
for(int聽i=0;i<side_len;++i){
聽聽聽聽聽聽聽聽
for(int聽j=0;j<side_len;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
while(聽in.get(t)&&isspace(t)聽);
聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j]聽
=聽t-'0';
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽input();

聽聽聽聽
for(int聽w聽=2;w<=side_len;++w){
聽聽聽聽聽聽聽聽
int聽cnt聽=0;

聽聽聽聽聽聽聽聽
for(int聽i=0;i<side_len;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽j=0;j<side_len;++j){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i+w<=side_len&&j+w<=side_len){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j]聽
=聽dp[i][j]&&dp[i+1][j]&&dp[i][j+1]&&dp[i+1][j+1];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(dp[i][j])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cnt
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
if(cnt!=0){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<w<<""<<cnt<<endl;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-07-08 17:44 鍙戣〃璇勮
]]>
USACO 3.3 Shopping Offershttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89483.htmlYZYYZYTue, 07 Jul 2009 11:16:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89483.htmlhttp://www.shnenglu.com/yuziyu/comments/89483.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89483.html#Feedback2http://www.shnenglu.com/yuziyu/comments/commentRss/89483.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89483.htmldp[i][j][k][m][n]琛ㄧず絎?-4縐嶇墿鍝佸垎鍒喘涔癷-n涓椂錛屾墍闇鐨勬渶灝忚垂鐢ㄣ?br />閭d箞瀵逛簬姣忎竴涓猳ffer
dp[i][j][k][m][n] = min ( dp[i][j][k][m][n], dp[i-o[0]][j-o[1]][k-o[2]][m-o[3]][n-o[4]]+offer.cost);

analysis涓彁鍑虹敤鏈鐭礬寰勭殑鏂規硶鏉ヨВ錛屾濊礬寰堝閥濡欍傛妸鈥濊鏈変笉鍚岀鏁板拰鏁伴噺鐨勭墿鍝佲滅殑綃瓙鐪嬩綔緇撶偣錛屾妸offer浣滀負杈?鎶婅喘涔頒竴浠剁墿鍝佺殑鍘熷浠鋒牸鐪嬫垚涓縐嶉鍖栫殑offer)錛屾妸浠鋒牸浣滀負杈歸暱搴︺傝繖鏍峰氨杞崲鎴愪粠綃瓙(0,0,0,0,0)鍒版墍姹傜粨鐐圭殑鏈鐭礬寰勯棶棰樸?br />
浠g爜濡備笅:
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"shopping.in");
ofstream聽fout(
"shopping.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽dp[6][6][6][6][6];

struct聽offer{
聽聽聽聽
int聽pro_num;
聽聽聽聽
int聽price;
聽聽聽聽
int聽product[5];
聽聽聽聽
int聽amount[5];
};

int聽offer_num;
offer聽offers[
100];
int聽map[1000]; //product id鍒扳濇寜鐗╁搧鍑虹幇欏哄簭鎵緇欑殑緙栧彿鈥滅殑鏄犲皠
int聽price[1000];//product id瀵瑰簲鐨勭墿鍝佷環鏍?br />int聽product_num;//鐗╁搧鎬繪暟鐩?br />int聽products[5];//瀛樻斁product id
int聽amount[5];//product 鎵闇鐨勬暟閲?br />
void聽solve()
{
聽聽聽聽
in>>offer_num;

聽聽聽聽
for(int聽i=0;i<offer_num;++i){
聽聽聽聽聽聽聽聽
in>>offers[i].pro_num;
聽聽聽聽聽聽聽聽
for(int聽j=0;j<offers[i].pro_num;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
in>>offers[i].product[j]>>offers[i].amount[j];
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
in>>offers[i].price;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
int聽pro_idx聽=0;

聽聽聽聽
in>>product_num;

聽聽聽聽
for(int聽i=0;i<product_num;++i){
聽聽聽聽聽聽聽聽
in>>products[i];
聽聽聽聽聽聽聽聽
in>>amount[i];
聽聽聽聽聽聽聽聽
in>>price[i];
聽聽聽聽聽聽聽聽map[聽products[i]聽]聽
=聽i;
聽聽聽聽}

聽聽聽 //娌℃湁鎶樻墸鏃剁殑浠鋒牸
聽聽聽聽
for(int聽i=0;i<=5;++i)
聽聽聽聽聽聽聽聽
for(int聽j=0;j<=5;++j)
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽k=0;k<=5;++k)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽m=0;m<=5;++m)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽n=0;n<=5;++n){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j][k][m][n]聽
=
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
0]*i+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
1]*j+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
2]*k+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
3]*m+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
4]*n;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽
for(int聽i=0;i<=5;++i)
聽聽聽聽聽聽聽聽
for(int聽j=0;j<=5;++j)
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽k=0;k<=5;++k)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽m=0;m<=5;++m)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽n=0;n<=5;++n){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽tmp[5];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽s=0;s<offer_num;++s){

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽memset(tmp,
0,sizeof(tmp));聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽t=0;t<offers[s].pro_num;++t){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tmp[map[offers[s].product[t]]]聽
=聽offers[s].amount[t];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i>=tmp[0]&&j>=tmp[1]&&k>=tmp[2]&&m>=tmp[3]&&n>=tmp[4]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j][k][m][n]聽
=聽min(聽dp[i][j][k][m][n],
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i
-tmp[0]][j-tmp[1]][k-tmp[2]][m-tmp[3]][n-tmp[4]]+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽offers[s].price);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽
out<<dp[amount[0]][amount[1]][amount[2]][amount[3]][amount[4]]<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}


涓婇潰浠g爜鏈変釜涓ラ噸鐨刡ug錛岃阿璋㈢綉鍙嬧滄垜涔熷噾鐑椆"鎸囧嚭銆傜敱浜巑ap鎵鏈夊奸兘涓?銆傛墍浠ユ湭鍦ㄥ晢鍝佸垪琛ㄤ腑鍑虹幇鐨勫晢鍝佺殑map鍊奸兘涓?錛屽嵆閮芥槧灝勪負絎竴涓晢鍝併傜幇鏀規垚灝唌ap鍒濆鍖栦負-1錛屽茍澧炲姞鍒ゆ柇璇彞銆傛澶栧皢鍒濆鍖杁p鐨勮鍙ュ悎騫跺埌鍚庨潰錛屼互綆鍖栦唬鐮併?br />

#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"shopping.in");
ofstream聽fout(
"shopping.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽dp[6][6][6][6][6];

struct聽offer{
聽聽聽聽
int聽pro_num;
聽聽聽聽
int聽price;
聽聽聽聽
int聽product[5];
聽聽聽聽
int聽amount[5];
};

int聽offer_num;
offer聽offers[
100];
int聽map[1000];
int聽price[1000];
int聽product_num;
int聽products[5];
int聽amount[5];

void聽solve()
{
聽聽聽聽
in>>offer_num;

聽聽聽聽
for(int聽i=0;i<offer_num;++i){
聽聽聽聽聽聽聽聽
in>>offers[i].pro_num;
聽聽聽聽聽聽聽聽
for(int聽j=0;j<offers[i].pro_num;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
in>>offers[i].product[j]>>offers[i].amount[j];
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
in>>offers[i].price;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
int聽pro_idx聽=0;

聽聽聽聽
in>>product_num;

聽聽聽聽
//2009.07.27淇敼
聽聽聽聽memset(map,-1,sizeof(map));

聽聽聽聽
for(int聽i=0;i<product_num;++i){
聽聽聽聽聽聽聽聽
in>>products[i];
聽聽聽聽聽聽聽聽
in>>amount[i];
聽聽聽聽聽聽聽聽
in>>price[i];
聽聽聽聽聽聽聽聽map[聽products[i]聽]聽
=聽i;
聽聽聽聽}

聽聽聽聽
for(int聽i=0;i<=5;++i)
聽聽聽聽聽聽聽聽
for(int聽j=0;j<=5;++j)
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽k=0;k<=5;++k)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽m=0;m<=5;++m)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽n=0;n<=5;++n){

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j][k][m][n]聽
=
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
0]*i+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
1]*j+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
2]*k+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
3]*m+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽price[
4]*n;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
int聽tmp[5];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽s=0;s<offer_num;++s){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽memset(tmp,
0,sizeof(tmp));聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽t=0;t<offers[s].pro_num;++t){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
//2009.07.27淇敼
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if(聽map[offers[s].product[t]]!=-1)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tmp[map[offers[s].product[t]]]聽
=聽offers[s].amount[t];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i>=tmp[0]&&j>=tmp[1]&&k>=tmp[2]&&m>=tmp[3]&&n>=tmp[4]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j][k][m][n]聽
=聽min(聽dp[i][j][k][m][n],
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i
-tmp[0]][j-tmp[1]][k-tmp[2]][m-tmp[3]][n-tmp[4]]+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽offers[s].price);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽
out<<dp[amount[0]][amount[1]][amount[2]][amount[3]][amount[4]]<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}






YZY 2009-07-07 19:16 鍙戣〃璇勮
]]>
USACO 3.3 Riding The Fences http://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.htmlYZYYZYTue, 07 Jul 2009 08:59:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.htmlhttp://www.shnenglu.com/yuziyu/comments/89469.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89469.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89469.html闃呰鍏ㄦ枃

YZY 2009-07-07 16:59 鍙戣〃璇勮
]]>
錛婚棶棰樿В鍐沖蹇橈冀ping涓嶉歭ocalhosthttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89406.htmlYZYYZYMon, 06 Jul 2009 13:30:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89406.htmlhttp://www.shnenglu.com/yuziyu/comments/89406.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89406.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89406.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89406.html紜疄寰堝鎬紝鎼滀簡涓嬶紝鍚庢潵鍦╱buntu璁哄潧涓婂彂鐜幫紝鎵嶆兂璧鋒槸鎴戠殑/etc/network/interfaces鏂囦歡閰嶇疆闂銆?br />浠ュ墠鍦ㄦ墜鍔ㄦ敼榪欎釜鏂囦歡鐨勬椂鍊欙紝欏烘墜鎶妉o鎺ュ彛緇欏垹浜嗐傘傘?br />闅炬惎鍔ㄧ殑鏃跺檟 server涓鐩存姤閿欙紝娣誨姞涓妉o鎺ュ彛錛屽彧/etc/init.d/networking restart榪樻槸涓嶈鐨勶紝閲嶅惎椹笂灝辮В鍐充簡銆?br />璁板綍涓涓嬶紝澶囧繕銆?br />

YZY 2009-07-06 21:30 鍙戣〃璇勮
]]>
USACO 3.2 Sweet Butterhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.htmlYZYYZYMon, 06 Jul 2009 12:05:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.htmlhttp://www.shnenglu.com/yuziyu/comments/89393.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.html#Feedback2http://www.shnenglu.com/yuziyu/comments/commentRss/89393.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89393.html闃呰鍏ㄦ枃

YZY 2009-07-06 20:05 鍙戣〃璇勮
]]>
USACO 3.2 Magic Squareshttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.htmlYZYYZYMon, 06 Jul 2009 12:01:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.htmlhttp://www.shnenglu.com/yuziyu/comments/89392.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89392.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89392.html
#include聽<iostream>
#include聽
<fstream>
#include聽
<set>
#include聽
<queue>

usingnamespace聽std;

ifstream聽fin(
"msquare.in");
ofstream聽fout(
"msquare.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽final[8];
set<int>visited;
char聽result[8*7*6*5*4*3*2*1+1];

struct聽queue_node{
聽聽聽聽
int聽current[8];
聽聽聽聽queue_node聽
*parent;
聽聽聽聽
char聽op;
};

void聽op(int*current,char聽c)
{
聽聽聽聽
int聽tmp;
聽聽聽聽
switch(c){
聽聽聽聽聽聽聽聽
case'A':
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=0;i<4;++i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽swap(current[i],current[
7-i]);
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case'B':
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[3];
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=3;i>=1;--i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽current[i]聽
=聽current[i-1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
0]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[4];
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=4;i<=6;++i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽current[i]聽
=聽current[i+1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
7]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case'C':
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[6];
聽聽聽聽聽聽聽聽聽聽聽聽current[
6]聽=聽current[5];
聽聽聽聽聽聽聽聽聽聽聽聽current[
5]聽=聽current[2];
聽聽聽聽聽聽聽聽聽聽聽聽current[
2]聽=聽current[1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
1]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽}
}

int聽cur_value(int*cur)
{
聽聽聽聽
int聽res聽=0;
聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽res
*=10;
聽聽聽聽聽聽聽聽res
+=cur[i];
聽聽聽聽}

聽聽聽聽
return聽res;
}


void聽solve()
{
聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽
in>>final[i];
聽聽聽聽}

聽聽聽聽queue
<queue_node*>聽q;
聽聽聽聽queue_node聽
*node聽=new聽queue_node;
聽聽聽聽
for(int聽i=0;i<8;++i)
聽聽聽聽聽聽聽聽node
->current[i]聽=聽i+1;

聽聽聽聽node
->parent聽=聽NULL;

聽聽聽聽q.push(node);

聽聽聽聽
while(聽!q.empty()聽){
聽聽聽聽聽聽聽聽queue_node聽
*node聽=聽q.front();
聽聽聽聽聽聽聽聽q.pop();

聽聽聽聽聽聽聽聽
int聽cur聽=聽cur_value(node->current);
聽聽聽聽聽聽聽聽
if(聽visited.find(聽cur)聽!=聽visited.end())
聽聽聽聽聽聽聽聽聽聽聽聽
continue;
聽聽聽聽聽聽聽聽visited.insert(cur);

聽聽聽聽聽聽聽聽
bool聽ok聽=true;
聽聽聽聽聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
if(node->current[i]!=final[i]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ok聽
=false;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
if(ok){
聽聽聽聽聽聽聽聽聽聽聽聽
int聽i聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
while(node->parent!=NULL){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽result[i
++]聽=聽node->op;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node
=node->parent;
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
if(i==0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<0<<endl<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
out<<i<<endl;

聽聽聽聽聽聽聽聽聽聽聽聽
int聽j;
聽聽聽聽聽聽聽聽聽聽聽聽i
--;
聽聽聽聽聽聽聽聽聽聽聽聽
for(j=0;i>=0;i--,j++){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<result[i];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(j%60==59)聽out<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽
if(j%60!=0)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<endl;

聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
for(char聽c='A';c<='C';++c){
聽聽聽聽聽聽聽聽聽聽聽聽queue_node聽
*聽n聽=new聽queue_node;
聽聽聽聽聽聽聽聽聽聽聽聽memcpy(n
->current,node->current,sizeof(node->current));
聽聽聽聽聽聽聽聽聽聽聽聽op(n
->current,c);
聽聽聽聽聽聽聽聽聽聽聽聽n
->op聽=聽c;
聽聽聽聽聽聽聽聽聽聽聽聽n
->parent聽=聽node;
聽聽聽聽聽聽聽聽聽聽聽聽q.push(n);
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-06 20:01 鍙戣〃璇勮
]]>
USACO 3.2 Spinning Wheelshttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.htmlYZYYZYSat, 04 Jul 2009 12:49:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.htmlhttp://www.shnenglu.com/yuziyu/comments/89252.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89252.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89252.html鐢ㄤ竴涓暟緇勮褰曡兘閫忚繃0-359鐨勮疆瀛愮殑涓暟錛屽綋鍦ㄦ煇涓搴﹁疆瀛愮殑涓暟杈懼埌浜?錛屽垯璇存槑鍏夊彲浠ラ忚繃錛岃緭鍑哄嵆鍙?br />鍚﹀垯璇存槑鏄笉鍙兘鏈夊厜閫忚繃銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream in(
"spin.in");
ofstream out(
"spin.out");

struct聽wedge{
聽聽聽聽
int聽start;
聽聽聽聽
int聽extent;
};

int聽speed[5];
wedge聽wedges[
5][5];
int聽wedge_num[5];

void聽onesecond()
{
聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽wedges[i][j].start
+=speed[i];
聽聽聽聽聽聽聽聽聽聽聽wedges[i][j].start
%=360;
聽聽聽聽聽聽聽}
聽聽聽}聽
}

bool聽isok()
{
聽聽聽聽
int聽tmp[360];

聽聽聽聽memset(tmp,
0,sizeof(tmp));

聽聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽k=0;k<=wedges[i][j].extent;++k)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tmp[(wedges[i][j].start
+k)%360]++;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
for(int聽i=0;i<360;++i)
聽聽聽聽聽聽聽聽
if(tmp[i]==5)
聽聽聽聽聽聽聽聽聽聽聽聽
returntrue;

聽聽聽聽
returnfalse;
}

void聽solve()
{
聽聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽聽
in>>speed[i];
聽聽聽聽聽聽聽聽
in>>wedge_num[i];
聽聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽聽
in>>wedges[i][j].start>>wedges[i][j].extent;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽
out<<0<<endl;
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}

聽聽聽聽
for(int聽i=1;i<=360;++i){
聽聽聽聽聽聽聽聽onesecond();
聽聽聽聽聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<i<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽
return;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽
out<<"none"<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}



YZY 2009-07-04 20:49 鍙戣〃璇勮
]]>
久久国产午夜精品一区二区三区| 久久国产亚洲精品无码| 久久久精品无码专区不卡| 国产亚洲色婷婷久久99精品91| 国产精品成人无码久久久久久| 久久久久久av无码免费看大片| 久久99热这里只有精品66| 亚洲综合日韩久久成人AV| 99久久人妻无码精品系列蜜桃| 99久久精品国产毛片| 怡红院日本一道日本久久| 欧美精品福利视频一区二区三区久久久精品 | 国产综合免费精品久久久| 女同久久| 久久精品国产亚洲av麻豆小说 | 国内精品伊人久久久久妇| 久久人人妻人人爽人人爽| 国产AⅤ精品一区二区三区久久| 亚洲欧美一级久久精品| 97精品久久天干天天天按摩| 久久精品夜色噜噜亚洲A∨| 国产成人精品久久| 国产成人精品久久一区二区三区av | A级毛片无码久久精品免费| 嫩草影院久久国产精品| 久久久久久久精品妇女99| 狠狠色丁香婷婷综合久久来 | 久久精品一区二区| 97精品国产97久久久久久免费| 久久亚洲国产中v天仙www| 久久人人爽人人人人爽AV| 99久久精品无码一区二区毛片| 久久久久久久久波多野高潮| 狠狠综合久久综合中文88| 久久一日本道色综合久久| 人妻少妇精品久久| 99久久婷婷国产综合精品草原| 无码国内精品久久人妻| 亚洲精品tv久久久久| 国产亚洲成人久久| 久久国产精品久久国产精品|