锘??xml version="1.0" encoding="utf-8" standalone="yes"?>人人狠狠综合久久亚洲高清,色诱久久av,国产精品一久久香蕉国产线看观看http://www.shnenglu.com/sephiroth/archive/2010/09/01/125561.htmlSephiroth LeeSephiroth LeeWed, 01 Sep 2010 13:54:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125561.htmlhttp://www.shnenglu.com/sephiroth/comments/125561.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125561.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125561.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125561.html浠婂ぉ涓婂崍璁茬殑鏄嚎鎬х殑鍔ㄥ綊銆傝鐨勪緥棰樻湁錛?/p>
  1. 鏈哄櫒鍒嗛厤妯″瀷
  2. 鑸?/li>
  3. 妤兼闂
  4. 鐢板繉璧涢┈
  5. 鏈闀垮叕鍏卞瓙涓?/li>

鐒跺悗灝辨槸鏈夊叧鐭╁艦鐨勫姩鎬佽鍒掋傚涓嬶細

  1. 婊戦洩
  2. 宸ヤ笟鏃朵唬

榪樻湁鍖洪棿綾葷殑錛?/p>

  1. 鍑稿杈瑰艦鍒掑垎
  2. 鏈澶т箻縐?/li>
  3. 鐭沖瓙鍚堝茍錛堢敤鍒頒簡鍥涜竟褰笉絳夊紡錛?/li>
  4. 鏁板瓧娓告垙

鐒跺悗鏈変笁閬撴祴璇曢錛?/p>

  1. 鍥涘闂
  2. 鍏崇伅
  3. 浠誨姟瀹夋帓

涓嬪崍寮濮嬪皢鏍戝艦鐨勫姩鎬佽鍒掋?/p>

  1. 鑱氫細鐨勫揩涔?/li>
  2. 涓夎壊浜屽弶鏍?/a>
  3. 鐨囧鐪嬪畧
  4. 鐝犲疂
  5. 絎︽枃涔嬫梾錛堟渶澶т笌鏈灝忥級

娌℃湁鍐欑殑棰樼洰浠ュ悗浼氶愭瀹屾垚銆?/p>

Sephiroth Lee 2010-09-01 21:54 鍙戣〃璇勮
]]>
鏍戝艦鍔ㄦ佽鍒?涓夎壊浜屽弶鏍?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/09/01/125558.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Wed, 01 Sep 2010 13:41:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/09/01/125558.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125558.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/09/01/125558.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125558.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125558.html</trackback:ping><description><![CDATA[<p>銆愰棶棰樻弿榪般?/p> <p>涓媯典簩鍙夋爲鍙互鎸夌収濡備笅瑙勫垯琛ㄧず鎴愪竴涓敱0銆?銆? 緇勬垚鐨勫瓧絎﹀簭鍒楋紝鎴戜滑縐頒箣涓衡滀簩鍙夋爲搴忓垪S鈥濓細</p> <p>2琛ㄧず璇ユ爲鏈変袱涓瓙鑺傜偣錛?鍜屽垎鍒〃紺哄叾涓や釜瀛愭爲鐨勪簩鍙夋爲搴忓垪</p> <p>1琛ㄧず璇ユ爲鏈変竴涓瓙鑺傜偣錛?涓哄叾瀛愭爲鐨勪簩鍙夋爲搴忓垪</p> <p>0琛ㄧず璇ユ爲娌℃湁瀛愯妭鐐?/p> <p>浣犵殑浠誨姟鏄瀵逛竴媯典簩鍙夋爲鐨勮妭鐐硅繘琛屾煋鑹層傛瘡涓妭鐐瑰彲浠ヨ鏌撴垚綰㈣壊銆佺豢鑹叉垨钃濊壊銆傚茍涓旓紝涓涓妭鐐逛笌鍏跺瓙鑺傜偣鐨勯鑹插繀欏諱笉鍚岋紝濡傛灉璇ヨ妭鐐規湁涓や釜瀛愯妭鐐癸紝閭d箞榪欎袱涓瓙鑺傜偣鐨勯鑹蹭篃蹇呴』涓嶇浉鍚屻傜粰瀹氫竴媯典簩鍙夋爲鐨勪簩鍙夋爲搴忓垪錛岃姹傚嚭榪欐5鏍戜腑鏈澶氬拰鏈灝戞湁澶氬皯涓偣鑳藉琚煋鎴愮豢鑹層?/p> <p>銆愯緭鍏ユ枃浠躲?/p> <p>杈撳叆鏂囦歡鍚嶏細TRO.IN</p> <p>杈撳叆鏂囦歡浠呮湁涓琛岋紝涓嶈秴榪?0000 涓瓧絎︼紝琛ㄧず涓涓簩鍙夋爲搴忓垪銆?/p> <p>銆愯緭鍑烘枃浠躲?/p> <p>杈撳嚭鏂囦歡鍚嶏細TRO.OUT</p> <p>杈撳嚭鏂囦歡涔熷彧鏈変竴琛岋紝鍖呭惈涓や釜鏁幫紝渚濇琛ㄧず鏈澶氬拰鏈灝戞湁澶氬皯涓偣鑳藉琚?/p> <p>鏌撴垚緇胯壊銆?/p> <p>銆愭牱渚嬭緭鍏ャ?/p> <p>1122002010</p> <p>銆愭牱渚嬭緭鍑恒?/p> <p>5 2</p> <p>銆愬垎鏋愩?/p> <h1>1.鍔ㄥ綊鍒嗘瀽</h1> <p>鎷挎渶澶ф潵璇淬?/p> <p>姣忎釜鑺傜偣鐨勭姸鎬佸彧鏈変笁縐嶉鑹詫紝鎴戜滑鐢╢[i][0],f[i][1]鍒嗗埆浠h〃絎琲涓偣鏌撶豢鑹插拰涓嶇劧緇胯壊鐨勬渶澶氱殑鐐規暟銆傚洜涓哄鏋滀竴涓偣涓嶆煋緇胯壊錛岄偅涔堜粬鏌撳彟涓ょ棰滆壊鏄瓑浠風殑銆傚姝ゆ垜浠氨寰楀埌浜嗗涓嬬殑鍔ㄨ鏂圭▼錛?/p> <ul> <li>鍙跺瓙錛歠[i][0]=1; f[i][1]=0; <li>涓涓瓙鑺傜偣錛歠[i][0]=f[瀛愯妭鐐筣[1]; f[i][1]=max(f[瀛愯妭鐐筣[0],f[瀛愯妭鐐筣[1]); <li>涓や釜瀛愯妭鐐癸細f[i][0]=f[宸﹀効瀛怾[1]+f[鍙沖効瀛怾[1]; f[i][1]=max(f[宸﹀効瀛怾[1]+f[鍙沖効瀛怾[0],f[宸﹀効瀛怾[0]+f[鍙沖効瀛怾[1]);</li></ul> <p>鏈鍚庤緭鍑哄氨鏄痬ax(f[0][1],f[0][0])銆?/p> <p>鏈灝忕殑鍜屾渶澶х殑鐩稿悓銆?/p> <h1>2.鏍戠殑紜畾</h1> <p>鍥犱負鏄竴媯典簩鍙夋爲鐨勫墠搴忛亶鍘嗭紝閭d箞瀵逛簬涓涓湁瀛愯妭鐐圭殑鐐規潵璇達紝宸﹀効瀛愬氨鏄痠+1銆傛垜浠紩榪涗竴涓猯ink[i]錛岃〃紺轟互i涓烘牴鐨勫瓙鏍戞渶鍚庝竴涓偣鐨勬爣鍙鳳紝閭d箞r[i]=link[l[i]]+1銆?/p> <p>瀵逛簬link[l]錛屾垜浠姝ょ‘瀹氾細</p> <ul> <li>鍙跺瓙錛歭ink[l]=l; <li>涓涓瓙鑺傜偣錛歭ink[l]=link[l+1]; <li>涓や釜瀛愯妭鐐癸細link[l]=link[link[l+1]+1];</li></ul> <p>鐒跺悗灝辨槸瀹炵幇浜嗐傚洜涓鴻嚜宸卞紕寰楄繕鏄笉鏄緢鐔燂紝鎵撲簡涓よ妭璇俱?/p><pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 650px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 1: #include <stdio.h> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 2: #include <<span style="color: #0000ff">string</span>.h> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 3: #include <iostream> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 4: #define maxn 10010 </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 5: #define MAXINT 10000000 </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 6: <span style="color: #0000ff">using</span> <span style="color: #0000ff">namespace</span> std; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 7: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 8: <span style="color: #0000ff">char</span> s[maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 9: <span style="color: #0000ff">int</span> f[maxn][2]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 10: <span style="color: #0000ff">int</span> link[maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 11: <span style="color: #0000ff">int</span> n; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 12: <span style="color: #0000ff">int</span> l[maxn],r[maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 13: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 14: <span style="color: #0000ff">int</span> _find(<span style="color: #0000ff">int</span> x) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 15: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 16: <span style="color: #0000ff">if</span> (link[x]) <span style="color: #0000ff">return</span> link[x]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 17: <span style="color: #0000ff">if</span> (s[x]=='0') link[x]=x; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 18: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 19: <span style="color: #0000ff">if</span> (s[x]=='1') link[x]=_find(x+1); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 20: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 21: link[x]=_find(_find(x+1)+1); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 22: <span style="color: #0000ff">return</span> link[x]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 23: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 24: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 25: <span style="color: #0000ff">void</span> find1(<span style="color: #0000ff">int</span> x) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 26: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 27: <span style="color: #0000ff">if</span> (f[x][0]) <span style="color: #0000ff">return</span>; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 28: <span style="color: #0000ff">if</span> (s[x]=='0') </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 29: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 30: f[x][0]=1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 31: f[x][1]=0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 32: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 33: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 34: <span style="color: #0000ff">if</span> (s[x]=='1') </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 35: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 36: find1(l[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 37: f[x][0]=f[l[x]][1]+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 38: f[x][1]=max(f[l[x]][1],f[l[x]][0]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 39: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 40: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 41: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 42: find1(l[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 43: find1(r[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 44: f[x][0]=f[l[x]][1]+f[r[x]][1]+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 45: f[x][1]=max(f[l[x]][1]+f[r[x]][0],f[l[x]][0]+f[r[x]][1]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 46: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 47: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 48: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 49: <span style="color: #0000ff">void</span> find2(<span style="color: #0000ff">int</span> x) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 50: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 51: <span style="color: #0000ff">if</span> (f[x][0]<MAXINT) <span style="color: #0000ff">return</span>; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 52: <span style="color: #0000ff">if</span> (s[x]=='0') </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 53: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 54: f[x][0]=1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 55: f[x][1]=0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 56: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 57: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 58: <span style="color: #0000ff">if</span> (s[x]=='1') </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 59: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 60: find2(l[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 61: f[x][0]=f[l[x]][1]+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 62: f[x][1]=min(f[l[x]][1],f[l[x]][0]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 63: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 64: <span style="color: #0000ff">else</span> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 65: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 66: find2(l[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 67: find2(r[x]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 68: f[x][0]=f[l[x]][1]+f[r[x]][1]+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 69: f[x][1]=min(f[l[x]][1]+f[r[x]][0],f[l[x]][0]+f[r[x]][1]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 70: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 71: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 72: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 73: <span style="color: #0000ff">int</span> main() </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 74: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 75: freopen("<span style="color: #8b0000">tro.in</span>","<span style="color: #8b0000">r</span>",stdin); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 76: freopen("<span style="color: #8b0000">tro.out</span>","<span style="color: #8b0000">w</span>",stdout); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 77: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 78: scanf("<span style="color: #8b0000">%s</span>",s); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 79: n=strlen(s); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 80: _find(0); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 81: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 82: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 83: l[i]=i+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 84: r[i]=link[l[i]]+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 85: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 86: find1(0); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 87: printf("<span style="color: #8b0000">%d </span>",max(f[0][0],f[0][1])); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 88: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 89: f[i][0]=f[i][1]=MAXINT; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 90: find2(0); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 91: printf("<span style="color: #8b0000">%d\n</span>",min(f[0][0],f[0][1])); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 92: <span style="color: #0000ff">return</span> 0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 93: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 94: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125558.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-09-01 21:41 <a href="http://www.shnenglu.com/sephiroth/archive/2010/09/01/125558.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍖洪棿綾誨姩鎬佽鍒?鏁板瓧娓告垙http://www.shnenglu.com/sephiroth/archive/2010/09/01/125557.htmlSephiroth LeeSephiroth LeeWed, 01 Sep 2010 13:40:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125557.htmlhttp://www.shnenglu.com/sephiroth/comments/125557.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125557.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125557.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125557.html棰樼洰緗戜笂閮藉彲浠ユ壘鍒般?/p>

娉ㄦ剰鍒濆鍖杝[i][j]鐨勬椂鍊欒鍔犱笂100000鑰屼笉鏄?0錛侊紒錛佹垜鍌誨弶瀛愪簡= =

  1: #include <stdio.h>
  2: #define MAXINT 10000000
  3: #define maxn 200
  4: 
  5: int f[maxn][maxn][maxn][2];//0 max|||| 1 min
  6: int s[maxn][maxn];
  7: int a[maxn];
  8: int n,m;
  9: int maxans,minans=MAXINT;
 10: 
 11: void find(int x,int y,int t)
 12: {
 13:     if (f[x][y][t][0]) return;
 14:     if (t==1)
 15:     {
 16:         f[x][y][1][0]=f[x][y][1][1]=s[x][y];
 17:         return;
 18:     }
 19:     for (int k=x+t-1-1;k<y;++k)
 20:     {
 21:         find(x,k,t-1);
 22:         if (f[x][k][t-1][1]*s[k+1][y]<f[x][y][t][1]) f[x][y][t][1]=f[x][k][t-1][1]*s[k+1][y];
 23:         if (f[x][k][t-1][0]*s[k+1][y]>f[x][y][t][0]) f[x][y][t][0]=f[x][k][t-1][0]*s[k+1][y];
 24:     }
 25: }
 26: 
 27: int main()
 28: {
 29:     freopen("game.in","r",stdin);
 30:     freopen("game.out","w",stdout);
 31:     
 32:     scanf("%d%d",&n,&m);
 33:     for (int i=1;i<=n;++i)
 34:     {
 35:         scanf("%d",&a[i]);
 36:         a[i+n]=a[i];
 37:     }
 38:     for (int i=1;i<=2*n;++i)
 39:         for (int j=i;j<=2*n;++j)
 40:             for (int k=1;k<=m;++k)
 41:                 f[i][j][k][1]=MAXINT;
 42:     for (int i=1;i<=2*n;++i)
 43:         for (int j=i;j<=2*n;++j)
 44:             s[i][j]=(s[i][j-1]+a[j]+100000)%10;
 45:     for (int i=1;i<=n;++i) find(i,i+n-1,m);
 46:     for (int i=1;i<=n;++i)
 47:     {
 48:         if (f[i][i+n-1][m][0]>maxans) maxans=f[i][i+n-1][m][0];
 49:         if (f[i][i+n-1][m][1]<minans) minans=f[i][i+n-1][m][1];
 50:     }
 51:     printf("%d\n%d\n",minans,maxans);
 52:     return 0;
 53: }
 54: 


Sephiroth Lee 2010-09-01 21:40 鍙戣〃璇勮
]]>
鏁板闂-Black and Whitehttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125476.htmlSephiroth LeeSephiroth LeeTue, 31 Aug 2010 23:00:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125476.htmlhttp://www.shnenglu.com/sephiroth/comments/125476.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/09/01/125476.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125476.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125476.html銆愰鐩弿榪般?/p>

瀵繪壘涓涓敱n涓暣鏁扮粍鎴愮殑鏁板垪錛屽叾涓換鎰忚繛緇璸涓暣鏁頒箣鍜屼負姝o紝浠繪剰榪炵畫q涓暣鏁頒箣鍜屼負璐熴傝嫢涓嶅瓨鍦ㄨ繖鏍風殑鏁存暟鏁板垪錛屽垯杈撳嚭NO錛屽惁鍒欒緭鍑哄叾涓竴涓暟鍒椼?/p>

銆愯緭鍏ャ?/p>

瀵逛簬姣忎釜嫻嬭瘯鐐瑰皢緇欎綘M緇勬暟鎹紝瑕佹眰浣犲浜庢瘡緇勬暟鎹紝鍒ゆ柇鏄惁瀛樺湪榪欐牱鐨勬暣鏁版暟鍒椼?/p>

杈撳叆鐨勭涓琛屾槸涓涓鏁存暟M錛岋紙1<=N<=10000錛?鎺ヤ笅鏉ョ殑M琛屽搴擬緇勬暟鎹紝姣忚鏈変笁涓鏁存暟N銆丳銆丵錛?<=n,p,q<=10^8錛夈?/p>

銆愯緭鍑恒?/p>

杈撳嚭鏁版嵁鍏盢琛岋紝姣忚涓簓es鎴栬卬o錛屽鏋滅I緇勬暟鎹湁瑙o紝鍒欏湪絎琁琛岃緭鍑簓es錛屽惁鍒欒緭鍑簄o

銆愯緭鍏ヨ緭鍑虹ず渚嬨?/p>
杈撳叆(sequence.in) 杈撳嚭(sequence.out)
2
1 1 9
10 2 4
yes
no

銆愯瘎鍒嗘爣鍑嗐?/p>

瀵逛簬姣忎釜嫻嬭瘯鐐癸紝濡傛灉浣犺兘澶熷湪1S鍐呴氳繃姣忕粍鏁版嵁錛屼綘灝嗗緱鍒拌繖涓祴璇曠偣鐨勫垎鏁幫紝鍚﹀垯錛岃繖涓祴璇曠偣浣犲彧鑳藉緱0鍒嗐?/p>

銆愬垎鏋愩?/p>

鍘熼鐩槸瑕佹眰杈撳嚭涓縐嶅彲鑳界殑瑙o紝濡傛灉娌℃湁瑙e氨杈撳嚭-1銆傝繖鏍風殑璇濆氨瑕佺敤鍒板樊鍒嗙害鏉熴?/p>

鐜板湪鐨勮瘽錛屽彧闇瑕佷竴涓叕寮忋傚鏋滄湁瑙o紝搴旀弧瓚籌細n<=q+p-gcd(p,q)-1銆?/p>

  1: #include <stdio.h>
  2: #include <iostream>
  3: using namespace std;
  4: 
  5: int n,m,p,q;
  6: 
  7: int gcd(int a,int b)
  8: {
  9:     if (a<b) swap(a,b);
 10:     int t;
 11:     while (b!=0)
 12:     {
 13:         t=a;
 14:         a=b;
 15:         b=t%a;
 16:     }
 17:     return a;
 18: }
 19: 
 20: int main()
 21: {
 22:     freopen("sequence.in","r",stdin);
 23:     freopen("sequence.out","w",stdout);
 24:     
 25:     scanf("%d",&m);
 26:     for (int i=0;i<m;++i)
 27:     {
 28:         scanf("%d%d%d",&n,&p,&q);
 29:         if (n<=p+q+gcd(p,q)-1) printf("YES\n");
 30:         else printf("NO\n");
 31:     }
 32:     return 0;
 33: }
 34: 

涓嬮潰鏄垜鍐欑殑鏌ュ垎綰︽潫銆?/p>

  1: #include <stdio.h>
  2: #define MAXINT 1000000
  3: #define maxn 1010
  4: 
  5: struct ss
  6: {
  7:     int x,y,dis;
  8: } l[10000];
  9: 
 10: int s[maxn];
 11: int a[maxn];
 12: int d[maxn];
 13: int n,q,p,tot;
 14: 
 15: int main()
 16: {
 17:     scanf("%d%d%d",&n,&p,&q);
 18:     for (int i=0;i<=n;++i)
 19:         if (i+p>n) break;
 20:         else
 21:         {
 22:             l[++tot].x=i+p;
 23:             l[tot].y=i;
 24:             l[tot].dis=-1;
 25:         }
 26:     for (int i=0;i<=n;++i)
 27:         if (i+q>n) break;
 28:         else
 29:         {
 30:             l[++tot].x=i;
 31:             l[tot].y=i+q;
 32:             l[tot].dis=-1;
 33:         }
 34:     for (int i=1;i<=n;++i)
 35:     {
 36:         for (int j=1;j<=tot;++j)
 37:             if (d[l[j].y]>d[l[j].x]+l[j].dis)
 38:                 d[l[j].y]=d[l[j].x]+l[j].dis;
 39:         for (int j=1;j<=tot;++j)
 40:             if (d[l[j].y]>d[l[j].x]+l[j].dis)
 41:             {
 42:                 printf("-1\n");
 43:                 return 0;
 44:             }
 45:     }
 46:     for (int i=0;i<=n;++i)
 47:         s[i]=d[i];
 48:     for (int i=1;i<=n;++i) printf("%d\n",s[i]-s[i-1]);
 49:     return 0;
 50: }
 51: 


Sephiroth Lee 2010-09-01 07:00 鍙戣〃璇勮
]]>
&ldquo;闀挎矙涓涓涔?amp;rdquo;-day1http://www.shnenglu.com/sephiroth/archive/2010/08/31/125444.htmlSephiroth LeeSephiroth LeeTue, 31 Aug 2010 12:09:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/31/125444.htmlhttp://www.shnenglu.com/sephiroth/comments/125444.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/31/125444.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125444.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125444.html浠婂ぉ涓婂崍浠庝笢鍖烘惉涓滆タ鍒拌タ鍖恒?1鐐歸兘鏀舵嬀瀹屼簡錛岀劧鍚庡埌姘存埧娉間簡涓涓皬鏃剁殑姘淬?/p>

涓嬪崍涓ょ偣澶氱殑鏃跺欐浌鑰佸笀寮濮嬭璇俱?/p>

浠婂ぉ鐨勮紼嬫槸涓や釜鍐呭錛氬叏闈㈠垎鏋愯瘯棰橈紝鍔ㄦ佽鍒掋?/p>

鏇硅佸笀鎷夸粬緇欒嚜宸辯殑瀛︾敓甯冪疆鐨勪換鍔″仛渚嬪瓙錛屽ぇ姒傜殑璇翠簡涓涓嬩粠涓涓鐩殑妯″瀷鍒板畬鏁寸殑棰樼洰鐨勮繃紼嬨傞鍏堟浌鑰佸笀緇欎簡4閬撻鐩紝閮藉彧鏄ぇ姒傜殑鎻忚堪銆傜劧鍚庡皢姣忎釜鏉′歡瀹氫弗璋ㄣ傜‘瀹氳緭鍏ヨ緭鍑虹殑鏍煎紡銆傚垎鏋愬彲浠ョ敤浠涔堢畻娉曪紝姣忕綆楁硶鐨勬椂闂村鏉傚害浠ュ強鍙互閫氳繃鐨勬暟鎹寖鍥淬傛牴鎹畻娉曞畾鍑烘暟鎹紝鍐欏嚭鏍囩▼銆傛浌鑰佸笀璇翠粬浠殑瀛︾敓姣忎釜浜洪氳繃鑷繁鐨勫垎鏋愶紝鍋氬嚭10涓暟鎹紝鐒跺悗澶ф100澶氫釜嫻嬭瘯鐐規潵嫻嬭瘯姣忎釜浜哄啓鐨勭▼搴忋?/p>

浠ヤ笅鏄?閬撻鐩傜浜岄鏈変簺鐡墮錛屼竴浼氬啀鍙戙?/p>

  1. 鍔ㄦ佽鍒?璧拌糠瀹棶棰?/a>
  2. 絀虹己
  3. 璐績-涔板僵紲?/a>
  4. 鏁板闂-Black and White


Sephiroth Lee 2010-08-31 20:09 鍙戣〃璇勮
]]>
鏁板闂-Black and Whitehttp://www.shnenglu.com/sephiroth/archive/2010/08/31/125441.htmlSephiroth LeeSephiroth LeeTue, 31 Aug 2010 11:59:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/31/125441.htmlhttp://www.shnenglu.com/sephiroth/comments/125441.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/31/125441.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125441.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125441.html銆愰鐩弿榪般?/p>

瀵繪壘涓涓敱n涓暣鏁扮粍鎴愮殑鏁板垪錛屽叾涓換鎰忚繛緇璸涓暣鏁頒箣鍜屼負姝o紝浠繪剰榪炵畫q涓暣鏁頒箣鍜屼負璐熴傝嫢涓嶅瓨鍦ㄨ繖鏍風殑鏁存暟鏁板垪錛屽垯杈撳嚭NO錛屽惁鍒欒緭鍑哄叾涓竴涓暟鍒椼?/p>

銆愯緭鍏ャ?/p>

瀵逛簬姣忎釜嫻嬭瘯鐐瑰皢緇欎綘M緇勬暟鎹紝瑕佹眰浣犲浜庢瘡緇勬暟鎹紝鍒ゆ柇鏄惁瀛樺湪榪欐牱鐨勬暣鏁版暟鍒椼?/p>

杈撳叆鐨勭涓琛屾槸涓涓鏁存暟M錛岋紙1<=N<=10000錛?鎺ヤ笅鏉ョ殑M琛屽搴擬緇勬暟鎹紝姣忚鏈変笁涓鏁存暟N銆丳銆丵錛?<=n,p,q<=10^8錛夈?/p>

銆愯緭鍑恒?/p>

杈撳嚭鏁版嵁鍏盢琛岋紝姣忚涓簓es鎴栬卬o錛屽鏋滅I緇勬暟鎹湁瑙o紝鍒欏湪絎琁琛岃緭鍑簓es錛屽惁鍒欒緭鍑簄o

銆愯緭鍏ヨ緭鍑虹ず渚嬨?/p>
杈撳叆(sequence.in) 杈撳嚭(sequence.out)
2
1 1 9
10 2 4
yes
no

銆愯瘎鍒嗘爣鍑嗐?/p>

瀵逛簬姣忎釜嫻嬭瘯鐐癸紝濡傛灉浣犺兘澶熷湪1S鍐呴氳繃姣忕粍鏁版嵁錛屼綘灝嗗緱鍒拌繖涓祴璇曠偣鐨勫垎鏁幫紝鍚﹀垯錛岃繖涓祴璇曠偣浣犲彧鑳藉緱0鍒嗐?/p>

銆愬垎鏋愩?/p>

鍘熼鐩槸瑕佹眰杈撳嚭涓縐嶅彲鑳界殑瑙o紝濡傛灉娌℃湁瑙e氨杈撳嚭-1銆傝繖鏍風殑璇濆氨瑕佺敤鍒板樊鍒嗙害鏉熴?/p>

鐜板湪鐨勮瘽錛屽彧闇瑕佷竴涓叕寮忋傚鏋滄湁瑙o紝搴旀弧瓚籌細n<=q+p+gcd(p,q)-1銆?/p>

  1: #include <stdio.h>
  2: #include <iostream>
  3: using namespace std;
  4: 
  5: int n,m,p,q;
  6: 
  7: int gcd(int a,int b)
  8: {
  9:     if (a<b) swap(a,b);
 10:     int t;
 11:     while (b!=0)
 12:     {
 13:         t=a;
 14:         a=b;
 15:         b=t%a;
 16:     }
 17:     return a;
 18: }
 19: 
 20: int main()
 21: {
 22:     freopen("sequence.in","r",stdin);
 23:     freopen("sequence.out","w",stdout);
 24:     
 25:     scanf("%d",&m);
 26:     for (int i=0;i<m;++i)
 27:     {
 28:         scanf("%d%d%d",&n,&p,&q);
 29:         if (n<=p+q+gcd(p,q)-1) printf("YES\n");
 30:         else printf("NO\n");
 31:     }
 32:     return 0;
 33: }
 34: 


Sephiroth Lee 2010-08-31 19:59 鍙戣〃璇勮
]]>
璐績-涔板僵紲?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125440.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Tue, 31 Aug 2010 11:55:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125440.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125440.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125440.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125440.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125440.html</trackback:ping><description><![CDATA[<p>銆愰棶棰樻弿榪般?/p> <p>鐢佃閲岄潰姝f斁鐫鈥滄娊鐧句竾澶у錛岃耽騫哥鐢熸椿鈥濈殑瀹d紶騫垮憡錛宐ird鐪嬪悗涔熸兂鍘昏瘯璇曟墜姘旓紝褰撶劧錛屼綔涓虹粡嫻庡闄㈢殑楂樻潗鐢燂紝浠栧彲涓嶅睉鍙槸鍗曠函鐨勫幓紕拌繍姘斻傜粡榪囦粬鐨勪竴鐣垎鏋愶紝鍙戠幇錛屽晢瀹跺湪褰╃エ閲岄潰鍋氫簡鎵嬭剼錛屼嬌寰楁瘡涓娊濂栫偣鐨勪腑濂栨鐜囦笉鏄畬鍏ㄤ竴鏍風殑錛岃屼笖闅忕潃鏃墮棿鐨勫彉鍖栬屽彉鍖栵紝涓嶈繃榪欑鍙樺寲鏄湁瑙勫緥鐨勩傚浜庣I涓娊濂栫偣錛屾渶寮濮嬬殑涓姒傜巼鏄櫨涓囧垎涔婸i錛屼互鍚庢瘡鎶戒竴寮犲僵紲ㄥ悗閮借閲嶆柊鎺掗槦錛岃姳璐圭殑鏃墮棿鏄疶鍒嗛挓錛屾瘡鎶戒竴嬈″噺灝戠殑姒傜巼涓篋i銆?/p> <p>鐢變簬鍙滅殑bird榪樻湁涓澶у爢鐨勪綔涓氭病鍋氾紝浠栧彧鑳芥娊鍑篐涓皬鏃跺幓涔板僵紲ㄣ傜敱浜庢娊濂栧湴鐐歸兘鍦ㄤ竴璺叕鍏辨苯杞︾殑綰胯礬涓婏紝鎵浠ユ曢夯鐑︾殑bird鍐沖畾鎸夎濺绔欓『搴忔娊濂栵紝褰撶劧錛宐ird鍙互浠庝換鎰忎竴绔欏紑濮嬫娊濂栵紝瀵逛簬緇忚繃鐨勬娊濂栫偣鍙互涔板僵紲紝涔熷彲浠ヤ笉涔般傚亣璁句粠絎琁涓娊濂栫偣鍒扮I+1涓娊濂栫偣闇瑕佸仛Ci鍒嗛挓鐨勬苯杞︺?/p> <p>Bird甯屾湜鑳藉湪鏈夐檺鐨凥涓皬鏃跺唴鑾峰緱鏈濂界殑榪愭皵鈥斺斿嵆鎶藉鐨勬鐜囧拰鏈澶с?/p> <p>[杈撳叆] 杈撳叆鏂囦歡鍚嶏細(tickt.in)</p> <p>絎竴琛屼負涓涓暣鏁皀錛岃〃紺烘娊濂栫偣鐨勪釜鏁幫紝1<=n<=200</p> <p>絎簩琛屾槸涓や釜鏁存暟H鍜孴錛?<=H<=10錛?<=T<=60銆?/p> <p>鎺ヤ笅鏉ョ殑n琛岋紝姣忚3涓暣鏁幫紝鍒嗗埆鏄疨i錛孌i錛孋i錛圕n=0錛夈?<=Pi<=10000錛孌i<=Pi錛?<=Ci<=600銆?/p> <p>[杈撳嚭] 杈撳嚭鏂囦歡鍚嶏細(tickt.out)</p> <p>鏂囦歡浠呮湁涓琛岋紝涓轟竴涓暣鏁幫紝鍗蟲娊濂栨鐜囧拰鐨勬渶澶у箋?/p> <p>銆愯緭鍏ヨ緭鍑烘牱渚嬨?/p> <table cellspacing="0" cellpadding="2" width="400" border="0"> <tbody> <tr> <td valign="top" width="200">tickt.in </td> <td valign="top" width="200">tickt.out</td></tr> <tr> <td valign="top" width="200"> <p>2</p> <p>1 20</p> <p>200 100 10</p> <p>300 200 0</p></td> <td valign="top" width="200">500</td></tr></tbody></table> <p>銆愭牱渚嬭鏄庛?/p> <p>棣栧厛錛宐ird浠?鍙峰紑濮嬫娊濂栵紝鑺辮垂20鍒嗛挓錛屽緱鍒版鐜?00錛岀劧鍚庡潗杞﹀埌2鍙鳳紝鑺辮垂10鍒嗛挓錛屽啀鑺?0鍒嗛挓寰楀埌姒傜巼300錛屾鐜囧拰鏄?00錛岃姳璐?0鍒嗛挓銆?/p> <p>銆愯瘎鍒嗘爣鍑嗐?/p> <p>瀵逛簬姣忎釜嫻嬭瘯鐐癸紝濡傛灉浣犺兘澶熷湪瑙勫畾鐨勬椂闂村唴閫氳繃姣忕粍鏁版嵁錛屼綘灝嗗緱鍒拌繖涓祴璇曠偣鐨勫垎鏁幫紝鍚﹀垯錛岃繖涓祴璇曠偣浣犲彧鑳藉緱0鍒嗐?/p> <p>銆愬垎鏋愩?/p> <p>鐢盋EOI鐨勯挀楸兼敼緙栵紝鍏蜂綋鍙互鐪嬨婄畻娉曡壓鏈笌淇℃伅瀛︾珵璧涖婸13銆?/p><pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 650px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 1: #include <stdio.h> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 2: #include <iostream> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 3: #define maxn 210 </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 4: <span style="color: #0000ff">using</span> <span style="color: #0000ff">namespace</span> std; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 5: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 6: <span style="color: #0000ff">int</span> b[maxn][maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 7: <span style="color: #0000ff">int</span> p[maxn],d[maxn],c[maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 8: <span style="color: #0000ff">int</span> h,t,tot; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 9: <span style="color: #0000ff">struct</span> ss </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 10: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 11: <span style="color: #0000ff">int</span> pi,di; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 12: } hp[maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 13: <span style="color: #0000ff">int</span> remain,ans,teans,n; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 14: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 15: <span style="color: #0000ff">void</span> down(<span style="color: #0000ff">int</span> x) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 16: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 17: <span style="color: #0000ff">int</span> te=2*x; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 18: <span style="color: #0000ff">while</span> (te<=tot) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 19: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 20: <span style="color: #0000ff">if</span> ((te+1<=tot)&&(hp[te].pi<hp[te+1].pi)) ++te; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 21: <span style="color: #0000ff">if</span> (hp[x].pi>hp[te].pi) <span style="color: #0000ff">break</span>; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 22: swap(hp[x],hp[te]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 23: x=te; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 24: te=x*2; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 25: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 26: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 27: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 28: <span style="color: #0000ff">int</span> main() </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 29: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 30: freopen("<span style="color: #8b0000">ticket.in</span>","<span style="color: #8b0000">r</span>",stdin); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 31: freopen("<span style="color: #8b0000">ticket.out</span>","<span style="color: #8b0000">w</span>",stdout); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 32: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 33: scanf("<span style="color: #8b0000">%d%d%d</span>",&n,&h,&t); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 34: h*=60; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 35: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) scanf("<span style="color: #8b0000">%d%d%d</span>",&p[i],&d[i],&c[i]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 36: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 37: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=i+1;j<=n;++j) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 38: b[i][j]=b[i][j-1]+c[j-1]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 39: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 40: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=n;j>=i;--j) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 41: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 42: teans=0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 43: remain=h-b[i][j]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 44: memset(hp,0,<span style="color: #0000ff">sizeof</span>(hp)); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 45: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> k=1;k<=j-i+1;++k) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 46: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 47: hp[k].pi=p[i+k-1]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 48: hp[k].di=d[i+k-1]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 49: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 50: tot=j-i+1; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 51: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> k=j-i+1;k>=1;--k) down(k); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 52: <span style="color: #0000ff">while</span> ((remain>=t)&&(hp[1].pi>0)) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 53: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 54: teans+=hp[1].pi; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 55: hp[1].pi-=hp[1].di; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 56: remain-=t; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 57: down(1); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 58: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 59: <span style="color: #0000ff">if</span> (teans>ans) ans=teans; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 60: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 61: printf("<span style="color: #8b0000">%d\n</span>",ans); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 62: <span style="color: #0000ff">return</span> 0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 63: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 64: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125440.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-31 19:55 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/31/125440.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍔ㄦ佽鍒?璧拌糠瀹棶棰?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125439.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Tue, 31 Aug 2010 11:52:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125439.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125439.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125439.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125439.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125439.html</trackback:ping><description><![CDATA[<p></p> <p>[棰樼洰鎻忚堪]</p> <p>鏈変竴涓猲*n鐨勮糠瀹紝姣忎釜鏂規牸閲岄兘鏈夌潃鐩稿簲鐨勬暟瀛椼備綘浠庡乏涓婅鍑哄彂錛屾瘡嬈″彲浠ュ悜涓婁笅宸﹀彸鍥涗釜鏂瑰悜鏈澶氱Щ鍔╧鏍鹼紝騫朵笖瑕佹眰浣犳瘡嬈″埌杈劇殑鏂規牸閲岀殑鏁板瓧蹇呴』澶т簬涓婁竴嬈℃墍鍦ㄦ柟鏍肩殑鏁板瓧銆傜幇鍦ㄨ姹備綘璧拌繃鐨勬柟鏍肩殑鎵鏈夋暟涔嬪拰鏈澶э紝闂繖涓渶澶у拰鏄灝戙?/p> <p>[杈撳叆]</p> <p>杈撳叆鏁版嵁絎竴琛屼負涓や釜姝f暣鏁癗銆並錛?<=N<=100,0<=K<=N錛?/p> <p>鎺ヤ笅鏉ョ殑n琛岋紝姣忚鏈塶涓笉瓚呰繃integer鑼冨洿鐨勬暣鏁幫紝琛ㄧず鍦板浘涓殑鏁般?/p> <p>[杈撳嚭]</p> <p>杈撳嚭鏁版嵁鍙湁涓琛岋紝涓烘渶澶х殑鍜屻?/p> <p>[杈撳叆杈撳嚭紺轟緥]</p> <p>杈撳叆(maze.in) 杈撳嚭(maze.out)</p> <p>3 1 25</p> <p>3 6 2</p> <p>4 7 9</p> <p>2 3 1</p> <p>[璇勫垎鏍囧噯]</p> <p>瀵逛簬姣忎釜嫻嬭瘯鏁版嵁錛屽鏋滀綘鑳藉寰楀嚭姝g‘鐨勭瓟妗堬紝閭d箞浣犲皢寰楀埌婊″垎錛屽惁鍒欏緱0鍒嗐?/p> <p>[鍒嗘瀽]</p> <p>寰堟槑鏄劇殑鍔ㄦ佽鍒掞紝搴旇鏄粠銆婃粦闆嬮偅閬撻鏀圭紪鑰屾潵鐨勩?/p><pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 650px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 1: #include <stdio.h> </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 2: #define maxn 110 </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 3: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 4: <span style="color: #0000ff">int</span> a[maxn][maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 5: <span style="color: #0000ff">int</span> f[maxn][maxn]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 6: <span style="color: #0000ff">int</span> n,ans,k; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 7: <span style="color: #0000ff">int</span> xx[4]={0,0,1,-1}; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 8: <span style="color: #0000ff">int</span> yy[4]={1,-1,0,0}; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 9: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 10: <span style="color: #0000ff">int</span> find(<span style="color: #0000ff">int</span> x,<span style="color: #0000ff">int</span> y) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 11: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 12: <span style="color: #0000ff">if</span> (f[x][y]) <span style="color: #0000ff">return</span> f[x][y]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 13: <span style="color: #0000ff">int</span> temx,temy; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 14: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<4;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 15: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=1;j<=k;++j) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 16: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 17: temx=x+xx[i]*j; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 18: temy=y+yy[i]*j; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 19: <span style="color: #0000ff">if</span> ((temx>0)&&(temx<=n)&&(temy>0)&&(temy<=n)) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 20: <span style="color: #0000ff">if</span> ((a[temx][temy]>a[x][y])&&(find(temx,temy)>f[x][y])) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 21: f[x][y]=find(temx,temy); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 22: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 23: f[x][y]+=a[x][y]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 24: <span style="color: #0000ff">return</span> f[x][y]; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 25: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 26: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 27: <span style="color: #0000ff">int</span> main() </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 28: { </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 29: freopen("<span style="color: #8b0000">maze.in</span>","<span style="color: #8b0000">r</span>",stdin); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 30: freopen("<span style="color: #8b0000">maze.out</span>","<span style="color: #8b0000">w</span>",stdout); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 31: </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 32: scanf("<span style="color: #8b0000">%d%d</span>",&n,&k); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 33: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 34: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=1;j<=n;++j) </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 35: scanf("<span style="color: #8b0000">%d</span>",&a[i][j]); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 36: printf("<span style="color: #8b0000">%d\n</span>",find(1,1)); </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 37: <span style="color: #0000ff">return</span> 0; </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #ffffff"> 38: } </pre><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> 39: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125439.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-31 19:52 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/31/125439.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍗沖皢寮濮嬬殑5澶╅泦璁?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125356.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Tue, 31 Aug 2010 01:57:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125356.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125356.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125356.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125356.html</trackback:ping><description><![CDATA[<p>璇蜂簡涓涓暱娌欑涓涓鐨勮佸笀錛屽緢鍑哄悕銆傚ぇ姒傚甫鍑烘潵浜嗗嚑鐧句釜鐪佷竴鍚с?/p> <p>浠庝粖澶╁紑濮嬭繘鍏ヤ負鏈?澶╃殑鈥滈暱娌欎竴涓涔犫濅笓棰樻椿鍔▇</p> <p>涔熻榪欏嚑澶╃敤涓嶄簡writer浜嗭紝鍥犱負瀹夎鐨勬椂鍊檓s瑕侀噸鏂板惎鍔ㄣ傝タ鍖虹殑鐢佃剳鏈夎繕鍘熷崱鐨勩?/p> <p>To be continued.</p><img src ="http://www.shnenglu.com/sephiroth/aggbug/125356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-31 09:57 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/31/125356.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍔ㄦ佽鍒?鏈灝忎笌鏈澶?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125337.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Mon, 30 Aug 2010 23:46:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125337.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125337.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/31/125337.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125337.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125337.html</trackback:ping><description><![CDATA[<p> <p>銆愰棶棰樻弿榪般?/p> <p>鍋氳繃浜嗕箻縐渶澶ц繖閬撻錛岀浉淇¤繖閬撻涔熼毦涓嶅掍綘銆?/p> <p>宸茬煡涓涓暟涓詫紝鍙互鍦ㄩ傚綋鐨勪綅緗姞鍏ヤ箻鍙鳳紙璁懼姞浜唊涓紝褰撶劧涔熷彲涓嶅姞錛屽嵆鍒嗘垚k+1涓儴鍒嗭級錛岃榪檏+1涓儴鍒嗙殑涔樼Н錛堝鏋渒=0,鍒欎箻縐嵆涓哄師鏁頒覆鐨勫鹼級瀵筸 鐨勪綑鏁幫紙鍗砿od m錛変負x;</p> <p>鐜版眰x鑳借揪鍒扮殑鏈灝忓煎強璇ユ儏鍐典笅k鐨勬渶灝忓鹼紝浠ュ強x鑳借揪鍒扮殑鏈澶у煎強璇ユ儏鍐典笅鐨刱鐨勬渶灝忓鹼紙鍙互瀛樺湪x鐨勬渶灝忓間笌鏈澶у肩浉鍚岀殑鎯呭喌錛夈?/p> <p>銆愯緭鍏ャ?/p> <p>絎竴琛屼負鏁頒覆錛岄暱搴︿負n 婊¤凍2<=n<=1000錛屼笖鏁頒覆涓笉瀛樺湪0錛?/p> <p>絎簩琛屼負m錛屾弧瓚?<=m<=50銆?/p> <p>銆愯緭鍑恒?/p> <p>鍥涗釜鏁幫紝鍒嗗埆涓簒鐨勬渶灝忓?鍜?璇ユ儏鍐典笅鐨刱錛屼互鍙妜鐨勬渶澶у煎拰 璇ユ儏鍐典笅鐨刱錛屼腑闂寸敤絀烘牸闅斿紑銆?/p> <p>銆愭牱渚嬭緭鍏ャ?/p> <p>4421</p> <p>22</p> <p>銆愭牱渚嬭緭鍑恒?/p> <p>0 1 21 0</p> <hr> </hr> <p>鏃㈢劧棰樼洰瑕佹眰鐨勯兘鏄箻鍙風殑鏈灝忓鹼紝閭d箞鎴戜滑鑷劧鍦板氨浼氭兂鍒板姩褰掓暟緇勪腑璁板綍涔樺彿鐨勬渶灝忓箋俧[i][j]琛ㄧず0~i鐨勪覆杈懼埌j榪欎釜浣欐暟鎵闇鏈灝戠殑涔樺彿鏁般傞澶勭悊b[i][j]琛ㄧず浠巌鍒癹鐨勬暟瀵筸鐨勪綑鏁般?/p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 1: #include <stdio.h> </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 2: #include <<span style="color: #0000ff">string</span>.h> </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 3: #define MAXINT 100000 </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 4: #define maxn 1010 </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 5: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 6: <span style="color: #0000ff">int</span> f[maxn][50]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 7: <span style="color: #0000ff">int</span> b[maxn][maxn]; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 8: <span style="color: #0000ff">int</span> n,m; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 9: <span style="color: #0000ff">char</span> s[maxn]; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 10: <span style="color: #0000ff">int</span> tem; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 11: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 12: <span style="color: #0000ff">int</span> main() </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 13: { </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 14: freopen("<span style="color: #8b0000">input.txt</span>","<span style="color: #8b0000">r</span>",stdin); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 15: freopen("<span style="color: #8b0000">output.txt</span>","<span style="color: #8b0000">w</span>",stdout); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 16: </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 17: scanf("<span style="color: #8b0000">%s%d</span>",s,&m); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 18: n=strlen(s); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 19: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 20: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=0;j<m;++j) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 21: f[i][j]=MAXINT; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 22: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 23: { </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 24: tem=(tem*10+s[i]-'0')%m; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 25: f[i][tem]=0; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 26: } </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 27: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 28: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 29: tem=0; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 30: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=i;j<n;++j) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 31: { </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 32: tem=(tem*10+s[j]-'0')%m; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 33: b[i][j]=tem; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 34: } </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 35: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 36: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 37: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=0;j<m;++j) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 38: <span style="color: #0000ff">if</span> (f[i][j]<MAXINT) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 39: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> k=i+1;k<n;++k) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 40: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 41: tem=(j*b[i+1][k])%m; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 42: <span style="color: #0000ff">if</span> (f[i][j]+1<f[k][tem]) f[k][tem]=f[i][j]+1; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 43: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 44: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<m;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 45: <span style="color: #0000ff">if</span> (f[n-1][i]<MAXINT) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 46: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 47: printf("<span style="color: #8b0000">%d %d </span>",i,f[n-1][i]); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 48: <span style="color: #0000ff">break</span>; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 49: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 50: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=m-1;i>=0;--i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 51: <span style="color: #0000ff">if</span> (f[n-1][i]<MAXINT) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 52: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 53: printf("<span style="color: #8b0000">%d %d\n</span>",i,f[n-1][i]); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 54: <span style="color: #0000ff">break</span>; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 55: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 56: <span style="color: #0000ff">return</span> 0; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 57: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 58: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125337.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-31 07:46 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/31/125337.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍔ㄦ佽鍒?鏈灝忔諱唬浠?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/30/125317.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Mon, 30 Aug 2010 13:59:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/30/125317.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125317.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/30/125317.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125317.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125317.html</trackback:ping><description><![CDATA[<p> <p>銆愰棶棰樻弿榪般?/p> <p>n涓漢鍦ㄥ仛浼犻掔墿鍝佺殑娓告垙,緙栧彿涓?-n銆?/p> <p>娓告垙瑙勫垯鏄繖鏍風殑錛氬紑濮嬫椂鐗╁搧鍙互鍦ㄤ換鎰忎竴浜烘墜涓婏紝浠栧彲鎶婄墿鍝佷紶閫掔粰鍏朵粬浜轟腑鐨勪換鎰忎竴浣嶏紱涓嬩竴涓漢鍙互浼犻掔粰鏈帴榪囩墿鍝佺殑浠繪剰涓浜恒?/p> <p>鍗崇墿鍝佸彧鑳界粡榪囧悓涓涓漢涓嬈★紝鑰屼笖姣忔浼犻掕繃紼嬮兘鏈変竴涓唬浠鳳紱涓嶅悓鐨勪漢浼犵粰涓嶅悓鐨勪漢鐨勪唬浠峰間箣闂存病鏈夎仈緋伙紱</p> <p>姹傚綋鐗╁搧緇忚繃鎵鏈塶涓漢鍚庯紝鏁翠釜榪囩▼鐨勬諱唬浠鋒槸澶氬皯銆?/p> <p>銆愯緭鍏ャ?/p> <p>絎竴琛屼負n,琛ㄧず鍏辨湁n涓漢錛?6>=n>=2錛夛紱</p> <p>浠ヤ笅涓簄*n鐨勭煩闃碉紝絎琲+1琛屻佺j鍒楄〃紺虹墿鍝佷粠緙栧彿涓篿鐨勪漢浼犻掑埌緙栧彿涓簀鐨勪漢鎵鑺辮垂鐨勪唬浠鳳紝鐗瑰埆鐨勬湁絎琲+1琛屻佺i鍒椾負-1錛堝洜涓虹墿鍝佷笉鑳借嚜宸變紶緇欒嚜宸憋級錛屽叾浠栨暟鎹潎涓烘鏁存暟(<=10000)銆?/p> <p>(瀵逛簬50%鐨勬暟鎹紝n<=11)銆?/p> <p>銆愯緭鍑恒?/p> <p>涓涓暟錛屼負鏈灝忕殑浠d環鎬誨拰銆?/p> <p>銆愭牱渚嬭緭鍏ャ?/p> <p>2</p> <p>-1 9794</p> <p>2724 鈥?</p> <p>銆愭牱渚嬭緭鍑恒?/p> <p>2724</p> <hr> </hr> <p><strike>鏃墮棿鍒頒簡鍟妦 鏄庡ぉ鍐嶇戶緇啓銆?/strike></p> <p>鏄竴涓敤浜岃繘鍒舵潵琛ㄧず鍥劇殑鐘舵佺殑鍔ㄦ佽鍒掞紝鎴栬呰鏄蹇嗗寲鎼滅儲銆俧[i][j]涓紝i鏉ヨ〃紺哄浘鐨勪簩榪涘埗鐘舵侊紝j琛ㄧず榪欎釜鐘舵佷腑絎竴涓偣銆?/p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 1: #include <stdio.h> </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 2: #include <iostream> </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 3: #define maxn 20 </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 4: #define MAXINT 1000000 </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 5: <span style="color: #0000ff">using</span> <span style="color: #0000ff">namespace</span> std; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 6: </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 7: <span style="color: #0000ff">int</span> dis[maxn][maxn]; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 8: <span style="color: #0000ff">int</span> n; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 9: <span style="color: #0000ff">int</span> f[70000][20]; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 10: <span style="color: #0000ff">int</span> ans=MAXINT; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 11: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 12: <span style="color: #0000ff">int</span> find(<span style="color: #0000ff">int</span> a,<span style="color: #0000ff">int</span> b) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 13: { </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 14: <span style="color: #0000ff">if</span> (f[a][b]!=MAXINT) <span style="color: #0000ff">return</span> f[a][b]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 15: <span style="color: #0000ff">int</span> tem=a; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 16: a-=(1<<b); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 17: <span style="color: #0000ff">if</span> (!a) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 18: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 19: f[tem][b]=0; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 20: <span style="color: #0000ff">return</span> 0; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 21: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 22: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 23: <span style="color: #0000ff">if</span> ((1<<i)&a) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 24: f[tem][b]=min(find(a,i)+dis[b][i],f[tem][b]); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 25: <span style="color: #0000ff">return</span> f[tem][b]; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 26: } </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 27: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 28: <span style="color: #0000ff">int</span> main() </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 29: { </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 30: freopen("<span style="color: #8b0000">input.txt</span>","<span style="color: #8b0000">r</span>",stdin); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 31: freopen("<span style="color: #8b0000">output.txt</span>","<span style="color: #8b0000">w</span>",stdout); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 32: </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 33: scanf("<span style="color: #8b0000">%d</span>",&n); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 34: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 35: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=0;j<n;++j) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 36: scanf("<span style="color: #8b0000">%d</span>",&dis[i][j]); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 37: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<(1<<n);++i) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 38: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=0;j<n;++j) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 39: f[i][j]=MAXINT; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 40: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=0;i<n;++i) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 41: <span style="color: #0000ff">if</span> (find((1<<n)-1,i)<ans) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 42: ans=find((1<<n)-1,i); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 43: printf("<span style="color: #8b0000">%d\n</span>",ans); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 44: <span style="color: #0000ff">return</span> 0; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 45: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 46: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125317.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-30 21:59 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/30/125317.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瀛楃涓插鐞?鐗涚殑浜哄搧http://www.shnenglu.com/sephiroth/archive/2010/08/30/125316.htmlSephiroth LeeSephiroth LeeMon, 30 Aug 2010 13:55:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/30/125316.htmlhttp://www.shnenglu.com/sephiroth/comments/125316.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/30/125316.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/125316.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/125316.html

銆愰棶棰樻弿榪般?/p>

澶╄媿鑻嶏紝閲庤尗鑼紝JSZX鐨勮彍楦熶滑鏉ュ埌OI鐗у満鏃呮父錛岀湅鍒頒簡濂藉濂藉鐨勭墰銆侽I鐗у満鎵鏈夌殑鐗涢兘瑙夊緱鑷繁鐨凴p鏈楂橈紙綆縐癛P鐗涳級錛屼負姝や粬浠父浜夎涓嶄紤銆備簬鏄紝浠栦滑璁㎎SZX鐨勮彍鑿滀滑鐢ㄦ渶鏈鏈寸礌鐨勬柟娉曟壘鍑鴻繖鍙猂P鐗涖?/p>

緇忚繃璁ㄨ錛屾渶鑿滅殑mmk鎯沖嚭浜嗘渶鏈寸礌鐨勬柟娉曪細

鎴戜滑瑕佷互cows鐨勫悕瀛椾負綰跨儲錛屾潵鎵懼嚭RP鐗涖?/p>

棣栧厛錛屽緱鍒皀澶寸墰鐨勫悕瀛楁竻鍗曪紙姣忓ご鐗涚殑鍚嶅瓧鏄竴涓粎鍖呭惈灝忓啓瀛楁瘝鐨勫瓧絎︿覆錛屼笖榪欎簺鐗涚殑璇誨啓鏂瑰紡姣旇緝鐗規畩鈥斾粠鍙沖埌宸︼級錛岀劧鍚庡姣忓ご鐗涜繘琛屾楠岋紝媯楠屾寜鐓х墰鐨勮鍐欐柟寮忚繘琛屻傝鍒欏涓嬶細

1錛嶳p 鐗涚殑鍚嶅瓧涓繀欏繪湁瀛愪覆鈥渏szxoier鈥?/p>

2錛庡皢鍚嶅瓧涓殑姣忎釜鈥渃ow鈥濈殑鏇挎崲涓衡渂ird鈥濄?/p>

3錛庤綆桼p鍊鹼細A涓哄悕瀛椾腑瀛愪覆鈥渞鈥濈殑涓暟錛?/p>

B涓哄悕瀛椾腑瀛愪覆鈥減鈥濈殑涓暟錛?/p>

C涓哄悕瀛椾腑瀛椾覆鈥渞p鈥濈殑涓暟錛?/p>

Rp鍊煎嵆涓?脳A+5脳B+20脳C銆?/p>

鏈鍚庤緭鍑篟P鐗涚殑鍚嶅瓧錛岃嫢鏈夊涓猂P鐗涳紝鍒欒緭鍑哄悕瀛楁渶鐭殑閭d釜銆?/p>

鍋囧浣犱篃鏄墰涓竴鍛橈紝灝界浣犲緢涓嶅睉榪欐牱鐨勬按棰橈紝浣嗘槸錛屼綘寰堟兂鍒癛P鐗涢偅閲屽垎鐐筊p錛屾墍浠ヤ綘鍐沖畾瑙e喅榪欓亾棰橈紝騫剁畻鍑篟P鐗涚殑Rp鏄灝戙?/p>

銆愯緭鍏ャ?/p>

絎竴琛岋紝涓涓暟n錛坣<=3000錛夈?/p>

鎺ヤ笅鏉ョ殑n琛岋紝姣忚涓涓瓧絎︿覆錛岄暱搴?lt;=300錛屾暟鎹繚璇佸瓨鍦≧P鐗涖?/p>

銆愯緭鍑恒?/p>

鍏變袱琛?/p>

絎竴琛屼負RP鐗涚殑鍚嶅瓧

絎簩琛屼負RP鐗涚殑Rp鍊?/p>

銆愭牱渚嬭緭鍏ャ?/p>

8

reioxzsjzmy

mmk

jwc

zxf

jwc

wangwei

xcy

yuhc

銆愭牱渚嬭緭鍑恒?/p>

reioxzsjzmy

5


鎴戠敤KMP鍖歸厤鐨勶紝浠g爜鎸虹煭錛岃繕姣攕tring.h鐨勫ソ鐢ㄣ?/p>

  1: #include <stdio.h>
  2: #include <string.h>
  3: #include <iostream>
  4: #define maxn 400
  5: using namespace std;
  6: 
  7: int f[maxn];
  8: char *aa="jszxoier",*bb="cow",*ee="rp",s[maxn];
  9: int a,b,c,tem,ans,anslen,len,m;
 10: int n;
 11: bool t;
 12: char anss[400];
 13: 
 14: void initf(char *s)
 15: {
 16:     memset(f,0,sizeof(f));
 17:     m=strlen(s);
 18:     int k=-1;
 19:     f[0]=-1;
 20:     for (int i=1;i<m;++i)
 21:     {
 22:         while ((k>-1)&&(s[k+1]!=s[i])) k=f[k];
 23:         if (s[k+1]==s[i]) ++k;
 24:         f[i]=k;
 25:     }
 26: }
 27: 
 28: void changef(char *s)
 29: {
 30:     initf(s);
 31:     int k;
 32:     for (int i=0;i<m;++i)
 33:     {
 34:         k=f[i];
 35:         while ((k>-1)&&(s[k+1]==s[i+1])) k=f[k];
 36:         f[i]=k;
 37:     }
 38: }
 39: 
 40: int main()
 41: {
 42:     freopen("input.txt","r",stdin);
 43:     freopen("output.txt","w",stdout);
 44:     
 45:     scanf("%d",&n);
 46:     for (int dt=1;dt<=n;++dt)
 47:     {
 48:         memset(s,0,sizeof(s));
 49:         scanf("%s",s);
 50:         strrev(s);
 51:         changef(aa);
 52:         len=strlen(s);
 53:         int k=-1;
 54:         t=0;
 55:         for (int i=0;i<len;++i)
 56:         {
 57:             while ((k>-1)&&(aa[k+1]!=s[i])) k=f[k];
 58:             if (aa[k+1]==s[i]) ++k;
 59:             if (k==m-1)
 60:             {
 61:                 t=1;
 62:                 break;
 63:             }
 64:         }
 65:         if (!t) continue;
 66:         a=b=c=0;
 67:         changef(bb);
 68:         for (int i=0;i<len;++i)
 69:         {
 70:             while ((k>-1)&&(bb[k+1]!=s[i])) k=f[k];
 71:             if (bb[k+1]==s[i]) ++k;
 72:             if (k==m-1) ++a;
 73:         }
 74:         for (int i=0;i<len;++i)
 75:             if (s[i]=='r') ++a;
 76:         for (int i=0;i<len;++i)
 77:             if (s[i]=='p') ++b;
 78:         changef(ee);
 79:         for (int i=0;i<len;++i)
 80:         {
 81:             while ((k>-1)&&(ee[k+1]!=s[i])) k=f[k];
 82:             if (ee[k+1]==s[i]) ++k;
 83:             if (k==m-1) ++c;
 84:         }
 85:         tem=a*5+b*5+c*20;
 86:         if (tem>ans)
 87:         {
 88:             memset(anss,0,sizeof(anss));
 89:             strcat(anss,s);
 90:             ans=tem;
 91:             anslen=len;
 92:         }
 93:         else
 94:             if (tem==ans)
 95:                 if (len<anslen)
 96:                 {
 97:                     memset(anss,0,sizeof(anss));
 98:                     strcat(anss,s);
 99:                 }
100:     }
101:     strrev(anss);
102:     printf("%s\n%d\n",anss,ans);
103:     return 0;
104: }
105: 


Sephiroth Lee 2010-08-30 21:55 鍙戣〃璇勮
]]>
鏁扮殑鍒掑垎-閫掓帹鍔ㄦ佽鍒?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125022.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Sat, 28 Aug 2010 03:04:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125022.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125022.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125022.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125022.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125022.html</trackback:ping><description><![CDATA[<p>鍙堜竴緇忓吀闂錛宯oip2001銆?/p> <p>鐢ㄥ埌浜嗗垎綾葷殑鎬濇兂銆傚浜巉[i][j]浠h〃i鍒嗕負j浠姐傛垜浠垎涓轟互涓嬩袱綾伙細</p> <ol> <li>姣忎喚閮芥病鏈?錛氶偅涔堟垜浠彧闇瑕佸皢姣忎喚閮藉噺1鐒跺悗淇濊瘉鏈塲浠姐傚嵆鍔犱笂f[i-j][j]銆?/li> <li>鑷沖皯鏈変竴浠?錛氶偅涔堟垜浠彁鍑?涓?,鍗沖姞涓奻[i-1][j-1]銆?/li></ol><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 1: #include <stdio.h> </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 2: #define maxn 300 </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 3: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 4: <span style="color: #0000ff">int</span> f[maxn][maxn]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 5: <span style="color: #0000ff">int</span> n,m; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 6: </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 7: <span style="color: #0000ff">int</span> main() </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 8: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 9: scanf("<span style="color: #8b0000">%d%d</span>",&n,&m); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 10: f[0][0]=1; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 11: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 12: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> j=1;j<=m;++j) </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 13: <span style="color: #0000ff">if</span> (i-j>=0) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 14: f[i][j]=f[i-j][j]+f[i-1][j-1]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 15: printf("<span style="color: #8b0000">%d\n</span>",f[n][m]); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 16: <span style="color: #0000ff">return</span> 0; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 17: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 18: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125022.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-28 11:04 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/28/125022.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏍哥數绔欓棶棰?閫掓帹鍔ㄦ佽鍒?/title><link>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125019.html</link><dc:creator>Sephiroth Lee</dc:creator><author>Sephiroth Lee</author><pubDate>Sat, 28 Aug 2010 02:29:00 GMT</pubDate><guid>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125019.html</guid><wfw:comment>http://www.shnenglu.com/sephiroth/comments/125019.html</wfw:comment><comments>http://www.shnenglu.com/sephiroth/archive/2010/08/28/125019.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sephiroth/comments/commentRss/125019.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sephiroth/services/trackbacks/125019.html</trackback:ping><description><![CDATA[<p>寰堢粡鍏哥殑闂錛岀敱浜庨掓帹鍏紡姣旇緝璇″紓錛屾墍浠ョ壒鍦扮殑璁板綍涓嬫潵銆?/p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 1: #include <stdio.h> </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 2: #define maxn 100 </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 3: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 4: <span style="color: #0000ff">unsigned</span> <span style="color: #0000ff">long</span> <span style="color: #0000ff">long</span> f[maxn]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 5: <span style="color: #0000ff">int</span> n,m; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 6: </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 7: <span style="color: #0000ff">int</span> main() </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 8: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 9: f[0]=1; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 10: scanf("<span style="color: #8b0000">%d%d</span>",&n,&m); </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 11: <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i=1;i<=n;++i) </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 12: { </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 13: f[i]=f[i-1]*2; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 14: <span style="color: #0000ff">if</span> (i-m-1>=0) f[i]-=f[i-m-1]; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 15: <span style="color: #0000ff">if</span> (i-m-1==-1) f[i]-=1; </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 16: } </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 17: printf("<span style="color: #8b0000">%I64d\n</span>",f[n]); </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 18: <span style="color: #0000ff">return</span> 0; </pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 19: } </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 20: </pre></pre><img src ="http://www.shnenglu.com/sephiroth/aggbug/125019.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sephiroth/" target="_blank">Sephiroth Lee</a> 2010-08-28 10:29 <a href="http://www.shnenglu.com/sephiroth/archive/2010/08/28/125019.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>棰樼洰&amp;鐭ヨ瘑鍒嗙被http://www.shnenglu.com/sephiroth/archive/2010/08/27/124957.htmlSephiroth LeeSephiroth LeeFri, 27 Aug 2010 10:08:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124957.htmlhttp://www.shnenglu.com/sephiroth/comments/124957.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124957.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/124957.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/124957.html1.鍔ㄦ佽鍒?/h1>
  1. 鏍戝艦渚濊禆鑳屽寘鈥斺旂櫨搴OIP鍚х紪紼嬫寫鎴樿禌"charge"
  2. 鏍哥數绔欓棶棰?閫掓帹鍔ㄦ佽鍒?/a>
  3. 鏁扮殑鍒掑垎-閫掓帹鍔ㄦ佽鍒?/a>
  4. 鍔ㄦ佽鍒?璧拌糠瀹棶棰?/a>
  5. 鍖洪棿綾誨姩鎬佽鍒?鏁板瓧娓告垙
  6. 鏍戝艦鍔ㄦ佽鍒?涓夎壊浜屽弶鏍?/a>

2.璐績

  1. 璐績-涔板僵紲?/a>

3.鏁板闂

  1. 鏁板闂-Black and White


Sephiroth Lee 2010-08-27 18:08 鍙戣〃璇勮
]]>
CTSC98-閫夎http://www.shnenglu.com/sephiroth/archive/2010/08/27/124956.htmlSephiroth LeeSephiroth LeeFri, 27 Aug 2010 10:05:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124956.htmlhttp://www.shnenglu.com/sephiroth/comments/124956.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124956.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/124956.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/124956.html鏈変緷璧栫殑鑳屽寘錛屾濂藉垰鍒氬鍒般?/p>
  1: #include <stdio.h>
  2: #include <stdlib.h>
  3: #define maxn 400
  4: 
  5: int f[maxn][maxn];
  6: int t[maxn];
  7: struct ss
  8: {
  9:     int root,num;
 10: } a[maxn];
 11: int n,m;
 12: int w[maxn];
 13: 
 14: int cmp(const void*a,const void*b)
 15: {
 16:     ss c=*(ss*)a,d=*(ss*)b;
 17:     if (c.root<d.root) return -1;
 18:     if (c.root>d.root) return 1;
 19:     return 0;
 20: }
 21: 
 22: void dp(int x)
 23: {
 24:     for (int i=t[x];i<t[x+1];++i)
 25:     {
 26:         int k=a[i].num;
 27:         for (int j=0;j<=m;++j) f[k][j]=f[x][j]+w[k];
 28:         dp(k);
 29:         for (int j=1;j<=m;++j)
 30:             if (f[k][j-1]>f[x][j])
 31:                 f[x][j]=f[k][j-1];
 32:     }
 33: }
 34: 
 35: int main()
 36: {
 37:     scanf("%d%d",&n,&m);
 38:     for (int i=1;i<=n;++i)
 39:     {
 40:         scanf("%d%d",&a[i].root,&w[i]);
 41:         a[i].num=i;
 42:     }
 43:     a[0].root=-1;
 44:     qsort(a,n+1,sizeof(ss),cmp);
 45:     for (int i=1;i<=n;++i)
 46:         if (!t[a[i].root])
 47:             t[a[i].root]=i;
 48:     t[n+1]=n+1;
 49:     for (int i=n;i>=0;--i)
 50:         if (!t[i])
 51:             t[i]=t[i+1];
 52:     dp(0);
 53:     printf("%d\n",f[0][m]);
 54:     return 0;
 55: }
 56: 


Sephiroth Lee 2010-08-27 18:05 鍙戣〃璇勮
]]>
鏍戝艦渚濊禆鑳屽寘&mdash;&mdash;鐧懼害NOIP鍚х紪紼嬫寫鎴樿禌&quot;charge&quot;http://www.shnenglu.com/sephiroth/archive/2010/08/27/124954.htmlSephiroth LeeSephiroth LeeFri, 27 Aug 2010 09:25:00 GMThttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124954.htmlhttp://www.shnenglu.com/sephiroth/comments/124954.htmlhttp://www.shnenglu.com/sephiroth/archive/2010/08/27/124954.html#Feedback0http://www.shnenglu.com/sephiroth/comments/commentRss/124954.htmlhttp://www.shnenglu.com/sephiroth/services/trackbacks/124954.html涓婂懆noip鍚ц繘琛岀殑緙栫▼鎸戞垬璧涖?/p>

鐩稿叧鍐呭瑙佲?a >銆愪紶閫侀棬銆戠櫨搴OIP鍚х紪紼嬫寫鎴樿禌鐩稿叧甯栧瓙鈥?/p>

絎笁棰樻槸涓閬撴湁渚濊禆鐨勮儗鍖呴棶棰樸備粖澶ヾev闂埌浜嗭紝浜庢槸鍙堝洖蹇嗕簡涓涓嬨傚緪鎸佽 澶х墰鐨勯泦璁槦璁烘枃涓叧浜庢硾鍖栫墿鍝佺殑騫惰繕鏄笉澶噦銆備絾鏄榪欑鑳屽寘鏈夌偣浜嗚嚜宸辯殑鎰熸偀銆?/p>

榪欓亾棰樼洰瀵規垜鏉ヨ鏈変袱涓惎鍙戠偣錛?/p>

  1. 瀵瑰鍎垮瓙鐨勫鐞嗭紝鐢ㄧ殑鏄痭logn鐨勯澶勭悊銆?
  2. 鏍戝艦鐨勮儗鍖呫?/li>

1.澶氬効瀛愮殑澶勭悊

鐢ㄧ粨鏋勪綋璁板綍鍏崇郴錛宎[i].root鏄i涓叧緋葷殑鐖惰妭鐐癸紝a[i].num鏄i涓叧緋葷殑瀛愯妭鐐廣傚皢鏁扮粍鎸塺oot鎺掑簭銆傜劧鍚庣敤t[i]璁板綍i榪欎釜鐐圭殑鍎垮瓙鍦╝涓殑璧峰浣嶇疆銆?/p>

  1: struct ss
  2: {
  3:     int root,num;
  4: } a[maxn];
  5: int t[maxn];
  6: 
  7: void init()
  8: {
  9:     qsort(a,n,sizeof(ss),cmp);
 10:     for (int i=1;i<=n;++i)
 11:         if (!t[a[i].root])
 12:             t[a[i].root]=i;
 13:     t[n+1]=n+1;
 14:     for (int i=n;i>0;--i)
 15:         if (!t[i])
 16:             t[i]=t[i+1];
 17: }
 18: 

榪欐牱絎琲涓偣鐨勫瓙鑺傜偣鍦╝涓殑浣嶇疆灝辨槸浠巘[i]鍒皌[i+1]-1銆?/p>

鍏嶅幓浜嗛摼琛ㄧ殑綣佺悙錛屾晥鐜囪繕鐩稿綋楂樸?/p>

2.鏍戝艦鐨勮儗鍖?/h1>

涓昏鎬濇兂灝辨槸瀵逛簬i鐨勮妭鐐箂錛宖[s]寮哄埗璧嬪間負f[i]錛岀劧鍚庡己鍒跺姞鍏[s],瀵箂榪涜澶勭悊錛屽啀鏇存柊f[i]銆?/p>

  1: void dp(int x)
  2: {
  3:     for (int i=t[x];i<t[x+1];++i)
  4:     {
  5:         int k=a[i].num;
  6:         for (int j=0;j<=V;++j) f[k][j]=f[x][j]+w[k];
  7:         dp(k);
  8:         for (int j=v[k];j<=V;++j)
  9:             if (f[k][j-v[k]]>f[x][j])
 10:                 f[x][j]=f[k][j-v[k]];
 11:     }
 12: }
鐩稿綋媯掔殑瑙e喅闂銆?

3.涓浜涗範棰?/h1>
  1. CTSC98-閫夎


]]> 91久久精品91久久性色| 国内精品综合久久久40p| 久久天天躁狠狠躁夜夜网站| 久久中文字幕视频、最近更新| 日本精品久久久中文字幕| 久久se精品一区二区| 精品精品国产自在久久高清| 国内精品久久久久影院日本| 久久99久久99精品免视看动漫| 国产毛片欧美毛片久久久| 久久免费的精品国产V∧| 99久久精品国产高清一区二区| 波多野结衣中文字幕久久| 久久精品无码一区二区三区| 久久婷婷久久一区二区三区| 国产成人精品久久一区二区三区av | 国产精品久久久久久影院| 欧美久久综合性欧美| 精品一久久香蕉国产线看播放| 精品乱码久久久久久夜夜嗨| 中文成人无码精品久久久不卡 | 久久久久av无码免费网| 久久99国产综合精品免费| 国产99久久久国产精品~~牛| 久久伊人五月天论坛| 日韩精品久久久肉伦网站| 色综合久久久久网| 国产69精品久久久久观看软件 | 伊人久久无码精品中文字幕| 一本久久a久久精品vr综合| 久久亚洲国产欧洲精品一| 综合久久一区二区三区| 99国产欧美精品久久久蜜芽| 久久久久亚洲精品中文字幕| 精品久久久久久久无码| 青春久久| 久久久久国产精品麻豆AR影院 | 精品国产乱码久久久久久呢| 中文字幕亚洲综合久久| 亚洲国产欧美国产综合久久| 国产A级毛片久久久精品毛片|