锘??xml version="1.0" encoding="utf-8" standalone="yes"?>无码久久精品国产亚洲Av影片,久久人人爽人人爽人人av东京热,激情久久久久久久久久http://www.shnenglu.com/397993401/category/13185.html鍦ㄩ剻瑙嗕腑鎴愰暱 璁板綍鎴愰暱鐨勭偣婊?/description>zh-cnSun, 29 May 2011 11:11:36 GMTSun, 29 May 2011 11:11:36 GMT60緙栫▼鐝犵帒銆錛嶃絎洓绔犱範棰?/title><link>http://www.shnenglu.com/397993401/archive/2011/05/29/147567.html</link><dc:creator>浠樼繑</dc:creator><author>浠樼繑</author><pubDate>Sun, 29 May 2011 02:56:00 GMT</pubDate><guid>http://www.shnenglu.com/397993401/archive/2011/05/29/147567.html</guid><wfw:comment>http://www.shnenglu.com/397993401/comments/147567.html</wfw:comment><comments>http://www.shnenglu.com/397993401/archive/2011/05/29/147567.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/397993401/comments/commentRss/147567.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/397993401/services/trackbacks/147567.html</trackback:ping><description><![CDATA[<p>絎洓绔犺鐨勬槸浜屽弶鎼滅儲錛岀劧鍚庝範棰樹腑瑕佹眰瀹炵幇浜屽弶鎼滅儲錛屽茍瑕佹眰鍦ㄤ竴涓湁搴忕殑鏁扮粍涓紝鏌ユ壘key錛屽茍榪斿洖絎竴嬈″嚭鐜扮殑涓嬫爣銆?/p> <p>     鏈鍒濈殑鎯蟲硶<strong>“鍏堥氳繃姝e父鐨勪簩鍒嗘煡鎵捐繑鍥炰竴涓綅緗畃os錛岀劧鍚庡湪浜屽垎鏌ユ壘0-pos錛屽鏋滄湁鍚堥傜殑newpos緇х畫0-newpos錛屼笉榪囨槸log2N + log2(N/2)+銆傘傘?#8221;</strong></p> <p><strong>    </strong>浼樺寲鍚?/p> <p>    1 姝e父鐨勪簩鍒嗘煡鎵捐繑鍥炰竴涓綅緗畃os 錛屾鏃剁殑pos  鏄敱  left  right 鐢熸垚 錛岃漿鍒扮浜屾</p> <p>    2 緇х畫璋冪敤 浜屽垎鎼滅儲 鍦?left 鍜?pos –1 涓煡鎵緆ey 錛?濡傛灉鎵懼埌 緇х畫絎簩姝ワ紝濡傛灉娌℃湁絎笁姝?/p> <p>    3 姝ゆ椂鍙互璇存槑 left – pos –1 涓?涓嶅瓨鍦?key 錛岄偅涔堝彲浠ヨ pos 灝辨槸絎竴嬈″嚭鐜扮殑涓嬫爣 </p> <p> </p><pre class="csharpcode"># include<stdio.h> <span id="njxvnhz" class="preproc">#define</span> DEBUG <span id="xnbnbln" class="kwrd">int</span> bsearch(<span id="pzxtjtj" class="kwrd">int</span> array[],<span id="vfrvfvt" class="kwrd">int</span> &start ,<span id="vnzlxdl" class="kwrd">int</span> &end ,<span id="vzbdpnt" class="kwrd">int</span> key) { <span id="jlpjlbz" class="kwrd">int</span> i,j; <span id="xzbdfvl" class="kwrd">int</span> mid; i = start; j = end ; <span id="djvfhhf" class="kwrd">while</span>(i <= j) { mid = (i+j)/2; #ifdef DEBUG <span id="lnzjttz" class="rem">// printf("now i j and mid is %d %d %d\n",i,j,mid);</span> <span id="xpblxfd" class="preproc">#endif</span> <span id="plfjljx" class="kwrd">if</span>(array[mid] == key) <span id="fbtxzpv" class="kwrd">return</span> mid; <span id="jtpzlhh" class="kwrd">else</span> <span id="lnpzbzj" class="kwrd">if</span>(array[mid] < key) i = mid + 1; <span id="zvrblbj" class="kwrd">else</span> j = mid - 1; } start = i,end = mid; <span id="jlfhrhp" class="kwrd">return</span> -1; } <span id="vpbdntj" class="kwrd">int</span> FirstBsearch(<span id="fhlvhfd" class="kwrd">int</span> array[],<span id="pjbnxnv" class="kwrd">int</span> start ,<span id="lrdnzvl" class="kwrd">int</span> end ,<span id="bbxhtzp" class="kwrd">int</span> key) { <span id="ntvfjpn" class="kwrd">int</span> i,j; <span id="ddhrbjr" class="kwrd">int</span> mid,pos; i = start; j = end ; mid = bsearch(array,start ,end ,key); <span id="fhbnpvd" class="kwrd">if</span>(array[mid] == key)<span id="tvzrntr" class="rem">//濡傛灉鎵懼埌浜?/span> { pos = mid; <span id="xhbdnlj" class="kwrd">while</span>( pos != -1 ) { j = pos -1; pos = bsearch(array ,i ,j ,key); } <span id="hdnztrx" class="kwrd">return</span> j+1; } <span id="jzjdvvt" class="kwrd">return</span> -1; } <span id="jtvxzfn" class="kwrd">int</span> main() { <span id="vdxblrz" class="kwrd">int</span> data[11] = {1,3,4,7,7,7,7,56,134,134,132487990}; <span id="rxjdntb" class="kwrd">int</span> key,i; <span id="xbvprzf" class="kwrd">int</span> start = 0,end =10; <span id="zlnzdrr" class="kwrd">for</span>(i = 0 ; i < 4; i ++) { scanf(<span id="jpjlnbh" class="str">"%d"</span>,&key); printf(<span id="tptrlbj" class="str">"%d"</span>,FirstBsearch(data,start,end,key)); } <span id="ntdhrpv" class="kwrd">return</span> 0; }</pre><br /><p>鎴戠嫭绔嬪崥瀹㈢殑銆<a >鍘熸枃</a>銆銆銆嬈㈣繋澶у璁塊棶錛屾壒璇勬寚姝o紱</p> <p><a >http://www.fuxiang90.me/?p=85</a></p><img src ="http://www.shnenglu.com/397993401/aggbug/147567.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/397993401/" target="_blank">浠樼繑</a> 2011-05-29 10:56 <a href="http://www.shnenglu.com/397993401/archive/2011/05/29/147567.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>嫻嬭瘯綾葷殑鏋愭瀯鍑芥暟http://www.shnenglu.com/397993401/archive/2011/02/27/140756.html浠樼繑浠樼繑Sun, 27 Feb 2011 13:23:00 GMThttp://www.shnenglu.com/397993401/archive/2011/02/27/140756.htmlhttp://www.shnenglu.com/397993401/comments/140756.htmlhttp://www.shnenglu.com/397993401/archive/2011/02/27/140756.html#Feedback0http://www.shnenglu.com/397993401/comments/commentRss/140756.htmlhttp://www.shnenglu.com/397993401/services/trackbacks/140756.html#include "thing.h" void function(Thing t) { Thing lt(106);//鍑芥暟緇撴潫鏃?璋冪敤鏋愭瀯 Thing* tp1 = new Thing(107); Thing* tp2 = new Thing(108);// 涓嶄細璋冪敤鏋愭瀯 delete tp1; } int main() { Thing t1(101), t2(102); // 鍦╩ain 鍑芥暟緇撴潫鏃?璋冪敤鏋愭瀯 Thing* tp1 = new Thing(103); function(t1);// 鍏朵腑t1 鍦╢unction 緇撴潫鏃惰皟鐢ㄦ瀽鏋? { /* nested block/scope */ Thing t3(104);// 璇ヤ綔鐢ㄥ煙緇撴潫鏃?璋冪敤鏋愭瀯 Thing* tp = new Thing(105);// 涓嶄細璋冪敤鏋愭瀯 } delete tp1; return 0; }
#ifndef THING_H_
#define THING_H_

#include <iostream>
#include <string>
using namespace std;

class Thing {
 public:
    Thing(int n) : m_Num(n) {
        
    }
    ~Thing() {
        cout << "destructor called: " 
             << m_Num << endl;
    }
    
 private:
    string m_String;
    int m_Num;
};
#endif

榪愯緇撴灉
destructor called: 107
destructor called: 106
destructor called: 101
destructor called: 104
destructor called: 103
destructor called: 102
destructor called: 101


浠樼繑 2011-02-27 21:23 鍙戣〃璇勮
]]>
int 鏈澶у?/title><link>http://www.shnenglu.com/397993401/archive/2010/09/14/126604.html</link><dc:creator>浠樼繑</dc:creator><author>浠樼繑</author><pubDate>Tue, 14 Sep 2010 09:04:00 GMT</pubDate><guid>http://www.shnenglu.com/397993401/archive/2010/09/14/126604.html</guid><wfw:comment>http://www.shnenglu.com/397993401/comments/126604.html</wfw:comment><comments>http://www.shnenglu.com/397993401/archive/2010/09/14/126604.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/397993401/comments/commentRss/126604.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/397993401/services/trackbacks/126604.html</trackback:ping><description><![CDATA[<div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; ">(</span><span style="color: #000000; ">1</span><span style="color: #000000; "><<</span><span style="color: #000000; ">31</span><span style="color: #000000; ">) </span><span style="color: #000000; ">-</span><span style="color: #000000; ">1</span><span style="color: #000000; ">; </span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #000000; "><br></span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #000000; ">鎵撴嫭鍙鋒槸鍥犱負 - 姣?lt;< 浼樺厛綰ч珮 </span></div><img src ="http://www.shnenglu.com/397993401/aggbug/126604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/397993401/" target="_blank">浠樼繑</a> 2010-09-14 17:04 <a href="http://www.shnenglu.com/397993401/archive/2010/09/14/126604.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++ 榪愮畻絎︿紭鍏堢駭鍒楄〃http://www.shnenglu.com/397993401/archive/2010/08/14/123410.html浠樼繑浠樼繑Sat, 14 Aug 2010 02:07:00 GMThttp://www.shnenglu.com/397993401/archive/2010/08/14/123410.htmlhttp://www.shnenglu.com/397993401/comments/123410.htmlhttp://www.shnenglu.com/397993401/archive/2010/08/14/123410.html#Feedback0http://www.shnenglu.com/397993401/comments/commentRss/123410.htmlhttp://www.shnenglu.com/397993401/services/trackbacks/123410.html

C++ 榪愮畻絎︿紭鍏堢駭鍒楄〃

http://www.cppreference.com/operator_precedence.html 
PrecedenceOperatorDescriptionExampleAssociativity
1 ()
[]
->
.
::
++
--
Grouping operator
Array access
Member access from a pointer
Member access from an object
Scoping operator
Post-increment
Post-decrement
(a + b) / 4;
array[4] = 2;
ptr->age = 34;
obj.age = 34;
Class::age = 2;
for( i = 0; i < 10; i++ ) ...
for( i = 10; i > 0; i-- ) ...
left to right
2 !
~
++
--
-
+
*
&
(type)
sizeof
Logical negation
Bitwise complement
Pre-increment
Pre-decrement
Unary minus
Unary plus
Dereference
Address of
Cast to a given type
Return size in bytes
if( !done ) ...
flags = ~flags;
for( i = 0; i < 10; ++i ) ...
for( i = 10; i > 0; --i ) ...
int i = -1;
int i = +1;
data = *ptr;
address = &obj;
int i = (int) floatNum;
int size = sizeof(floatNum);
right to left
3 ->*
.*
Member pointer selector
Member pointer selector
ptr->*var = 24;
obj.*var = 24;
left to right
4 *
/
%
Multiplication
Division
Modulus
int i = 2 * 4;
float f = 10 / 3;
int rem = 4 % 3;
left to right
5 +
-
Addition
Subtraction
int i = 2 + 3;
int i = 5 - 1;
left to right
6 <<
>>
Bitwise shift left
Bitwise shift right
int flags = 33 << 1;
int flags = 33 >> 1;
left to right
7 <
<=
>
>=
Comparison less-than
Comparison less-than-or-equal-to
Comparison greater-than
Comparison geater-than-or-equal-to
if( i < 42 ) ...
if( i <= 42 ) ...
if( i > 42 ) ...
if( i >= 42 ) ...
left to right
8 ==
!=
Comparison equal-to
Comparison not-equal-to
if( i == 42 ) ...
if( i != 42 ) ...
left to right
9 & Bitwise AND flags = flags & 42; left to right
10 ^ Bitwise exclusive OR flags = flags ^ 42; left to right
11 | Bitwise inclusive (normal) OR flags = flags | 42; left to right
12 && Logical AND if( conditionA && conditionB ) ... left to right
13 || Logical OR if( conditionA || conditionB ) ... left to right
14 ? : Ternary conditional (if-then-else) int i = (a > b) ? a : b; right to left
15 =
+=
-=
*=
/=
%=
&=
^=
|=
<<=
>>=
Assignment operator
Increment and assign
Decrement and assign
Multiply and assign
Divide and assign
Modulo and assign
Bitwise AND and assign
Bitwise exclusive OR and assign
Bitwise inclusive (normal) OR and assign
Bitwise shift left and assign
Bitwise shift right and assign
int a = b;
a += 3;
b -= 4;
a *= 5;
a /= 2;
a %= 3;
flags &= new_flags;
flags ^= new_flags;
flags |= new_flags;
flags <<= 2;
flags >>= 2;
right to left
16 , Sequential evaluation operator for( i = 0, j = 0; i < 10; i++, j++ ) ... left to right



浠樼繑 2010-08-14 10:07 鍙戣〃璇勮
]]>
map鐨勪竴涓敤娉?/title><link>http://www.shnenglu.com/397993401/archive/2010/06/26/118780.html</link><dc:creator>浠樼繑</dc:creator><author>浠樼繑</author><pubDate>Sat, 26 Jun 2010 09:08:00 GMT</pubDate><guid>http://www.shnenglu.com/397993401/archive/2010/06/26/118780.html</guid><wfw:comment>http://www.shnenglu.com/397993401/comments/118780.html</wfw:comment><comments>http://www.shnenglu.com/397993401/archive/2010/06/26/118780.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/397993401/comments/commentRss/118780.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/397993401/services/trackbacks/118780.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">map 涓祵濂梞ap 浣跨敤 <br><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">map</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;"> </span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> std;<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    </span><span style="color: #0000ff;">string</span><span style="color: #000000;"> ss,ss1;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k,n,m,t</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>    cin</span><span style="color: #000000;">>></span><span style="color: #000000;">n;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (n</span><span style="color: #000000;">--</span><span style="color: #000000;">)<br>    {<br>        map</span><span style="color: #000000;"><</span><span style="color: #000000;"> </span><span style="color: #0000ff;">string</span><span style="color: #000000;">,map</span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">,</span><span style="color: #0000ff;">int</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">></span><span style="color: #000000;">mm;</span><span style="color: #008000;">//</span><span style="color: #008000;"> 鍙互宓屽map</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (t</span><span style="color: #000000;">></span><span style="color: #000000;">1</span><span style="color: #000000;">) cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>        cin</span><span style="color: #000000;">>></span><span style="color: #000000;">k;<br>        </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (k</span><span style="color: #000000;">--</span><span style="color: #000000;">)<br>        {<br>            cin</span><span style="color: #000000;">>></span><span style="color: #000000;">ss1</span><span style="color: #000000;">>></span><span style="color: #000000;">ss</span><span style="color: #000000;">>></span><span style="color: #000000;">m;<br>            mm[ss][ss1]</span><span style="color: #000000;">+=</span><span style="color: #000000;">m;<br>        }<br>        </span><span style="color: #008000;">//</span><span style="color: #008000;"> map鍐呴儴鏄粯璁ゆ帓搴忕殑</span><span style="color: #008000;"><br></span><span style="color: #000000;">        map</span><span style="color: #000000;"><</span><span style="color: #000000;"> </span><span style="color: #0000ff;">string</span><span style="color: #000000;">,map</span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">,</span><span style="color: #0000ff;">int</span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">></span><span style="color: #000000;">::iterator itr;<br>        map</span><span style="color: #000000;"><</span><span style="color: #000000;"> </span><span style="color: #0000ff;">string</span><span style="color: #000000;">,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> </span><span style="color: #000000;">></span><span style="color: #000000;"> ::iterator itr1;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (itr</span><span style="color: #000000;">=</span><span style="color: #000000;">mm.begin();itr</span><span style="color: #000000;">!=</span><span style="color: #000000;">mm.end();itr</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">(</span><span style="color: #000000;">*</span><span style="color: #000000;">itr).first</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>            </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (itr1</span><span style="color: #000000;">=</span><span style="color: #000000;">(</span><span style="color: #000000;">*</span><span style="color: #000000;">itr).second.begin();itr1</span><span style="color: #000000;">!=</span><span style="color: #000000;">(</span><span style="color: #000000;">*</span><span style="color: #000000;">itr).second.end();itr1</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>                cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;">   |----</span><span style="color: #000000;">"</span><span style="color: #000000;"><<</span><span style="color: #000000;">(</span><span style="color: #000000;">*</span><span style="color: #000000;">itr1).first</span><span style="color: #000000;"><<</span><span style="color: #000000;">'</span><span style="color: #000000;">(</span><span style="color: #000000;">'</span><span style="color: #000000;"><<</span><span style="color: #000000;">(</span><span style="color: #000000;">*</span><span style="color: #000000;">itr1).second</span><span style="color: #000000;"><<</span><span style="color: #000000;">'</span><span style="color: #000000;">)</span><span style="color: #000000;">'</span><span style="color: #000000;"><<</span><span style="color: #000000;">endl;<br>        }<br>        t</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    }<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> <br><img src ="http://www.shnenglu.com/397993401/aggbug/118780.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/397993401/" target="_blank">浠樼繑</a> 2010-06-26 17:08 <a href="http://www.shnenglu.com/397993401/archive/2010/06/26/118780.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏈夐亾璧勬牸璧?鏈夐亾鎼滅儲妗?/title><link>http://www.shnenglu.com/397993401/archive/2010/05/30/116713.html</link><dc:creator>浠樼繑</dc:creator><author>浠樼繑</author><pubDate>Sat, 29 May 2010 16:03:00 GMT</pubDate><guid>http://www.shnenglu.com/397993401/archive/2010/05/30/116713.html</guid><wfw:comment>http://www.shnenglu.com/397993401/comments/116713.html</wfw:comment><comments>http://www.shnenglu.com/397993401/archive/2010/05/30/116713.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/397993401/comments/commentRss/116713.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/397993401/services/trackbacks/116713.html</trackback:ping><description><![CDATA[<div class="hztzlfv" id="problemPageTitleDescrip" style="border: 1px solid #d0ddf9; margin: 0px; padding: 0px; height: 39px; background-image: url(http://poj.youdao.com/styles/images/section_nav_background.png); background-attachment: scroll; background-color: transparent; background-position: 0px 99%;">鏄ㄥぉ鏂綉 鍗氬娌℃湁鍐欏叏 鍛靛懙 <br> <div class="xdnpbzf" id="bottomMenu" style="margin: 0px; padding: 9px 16px 0px; overflow: hidden; font-size: 14px;"> <ul style="margin: 0pt; padding: 0pt; list-style-image: none; list-style-position: outside; list-style-type: none;"> <li style="margin: 0pt 8px 0pt 0pt; padding: 0pt; list-style-type: none; float: left; line-height: 24px;"><a style="border-style: solid; border-color: #9b898e #9b898e black; border-width: 1px; padding: 4px 10px 0px; text-decoration: none; color: #4ca6cf; font-weight: normal; outline-style: none; display: block;">鏌ョ湅</a></li> <li style="margin: 0pt 8px 0pt 0pt; padding: 0pt; list-style-type: none; float: left; line-height: 24px;"><a style="border-style: solid; border-color: #9b898e #9b898e black; border-width: 1px; padding: 4px 10px 0px; text-decoration: none; color: #4ca6cf; font-weight: normal; outline-style: none; display: block;">鎻愪氦</a></li> <li style="margin: 0pt 8px 0pt 0pt; padding: 0pt; list-style-type: none; float: left; line-height: 24px;"><a style="border-style: solid; border-color: #9b898e #9b898e black; border-width: 1px; padding: 4px 10px 0px; text-decoration: none; color: #686868; font-weight: normal; outline-style: none; display: block;">緇熻</a></li> <li style="margin: 0pt 8px 0pt 0pt; padding: 0pt; list-style-type: none; float: left; line-height: 24px;"><a style="border-style: solid; border-color: #9b898e #9b898e black; border-width: 1px; padding: 4px 10px 0px; text-decoration: none; color: #686868; font-weight: normal; outline-style: none; display: block;">璁ㄨ</a></li> </ul> </div> <br> </div> <div id="rphjltr" class="col-12" style="margin: 0px 10px; padding: 0px; float: left; display: inline; width: 700px;"><dl class="problem-params" style="margin: 0px; padding: 0px;"><dt style="margin: 0px; padding: 0px; color: white; display: inline; font-size: 12px; font-weight: bold; left: 613px; position: relative; top: -75px;">鏃墮棿闄愬埗: </dt><dd style="margin: 0px; padding: 0px; color: white; display: inline; font-size: 12px; font-weight: bold; left: 613px; position: relative; top: -75px;">1000ms</dd> <dt style="margin: 0px; padding: 0px; color: white; display: inline; font-size: 12px; font-weight: bold; left: 613px; position: relative; top: -75px;">鍐呭瓨闄愬埗: </dt><dd style="margin: 0px; padding: 0px; color: white; display: inline; font-size: 12px; font-weight: bold; left: 613px; position: relative; top: -75px;">131072kB</dd></dl><dl class="problem-content" style="margin: 0px; padding: 0px;"><dt style="margin: 0px; padding: 0px; font-weight: bold; font-size: 16px;">鎻忚堪</dt><dd style="margin: 12px 0px; padding: 0px;">鍦ㄦ湁閬撴悳绱㈡涓紝褰撹緭鍏ヤ竴涓垨鑰呭涓瓧絎︽椂錛屾悳绱㈡浼氬嚭鐜頒竴瀹氭暟閲忕殑鎻愮ず錛屽涓嬪浘鎵紺猴細<br><img src="http://poj.youdao.com/groups/youdao/suggest.jpg" style="border-width: 0px;"><br><br>鐜板湪緇欎綘N涓崟璇嶅拰涓浜涙煡璇紝璇瘋緭鍑烘彁紺虹粨鏋滐紝涓轟簡綆鍖栬繖涓棶棰橈紝鍙渶瑕佽緭鍑轟互鏌ヨ璇嶄負鍓嶇紑鐨勫茍涓旀寜瀛楀吀搴忔帓鍒楃殑鏈鍓嶉潰鐨?涓崟璇嶏紝濡傛灉絎﹀悎瑕佹眰鐨勫崟璇嶄竴涓篃娌℃湁璇峰彧杈撳嚭褰撳墠鏌ヨ璇嶃?/dd><dt style="margin: 0px; padding: 0px; font-weight: bold; font-size: 16px;">杈撳叆</dt><dd style="margin: 12px 0px; padding: 0px;">絎竴琛屾槸涓涓鏁存暟N錛岃〃紺鴻瘝琛ㄤ腑鏈塏涓崟璇嶃?br>鎺ヤ笅鏉ユ湁N琛岋紝姣忚閮芥湁涓涓崟璇嶏紝娉ㄦ剰璇嶈〃涓殑鍗曡瘝鍙兘鏈夐噸澶嶏紝璇峰拷鐣ユ帀閲嶅鍗曡瘝銆傛墍鏈夌殑鍗曡瘝閮界敱灝忓啓瀛楁瘝緇勬垚銆?br>鎺ヤ笅鏉ョ殑涓琛屾湁涓涓鏁存暟Q錛岃〃紺烘帴涓嬫潵鏈塓涓煡璇€?br>鎺ヤ笅鏉琛岋紝姣忚鏈変竴涓崟璇嶏紝琛ㄧず涓涓煡璇㈣瘝錛屾墍鏈夌殑鏌ヨ璇嶄篃閮芥槸鐢卞皬鍐欏瓧姣嶇粍鎴愶紝騫朵笖鎵鏈夌殑鍗曡瘝浠ュ強鏌ヨ鐨勯暱搴﹂兘涓嶈秴榪?0錛屼笖閮戒笉涓虹┖<br>鍏朵腑錛歂<=10000,Q<=10000</dd><dt style="margin: 0px; padding: 0px; font-weight: bold; font-size: 16px;">杈撳嚭</dt><dd style="margin: 12px 0px; padding: 0px;">瀵逛簬姣忎釜鏌ヨ錛岃緭鍑轟竴琛岋紝鎸夐『搴忚緭鍑鴻鏌ヨ璇嶇殑鎻愮ず緇撴灉錛岀敤絀烘牸闅斿紑銆?/dd><dt style="margin: 0px; padding: 0px; font-weight: bold; font-size: 16px;">鏍蜂緥杈撳叆</dt><dd style="margin: 12px 0px; padding: 0px;"> <pre style="border: 1px solid #dadada; margin: 0px; padding: 11px; overflow: auto; background-color: #f5f5f5; font-size: 12px; line-height: 1.3em;">10<br>a<br>ab<br>hello<br>that<br>those<br>dict<br>youdao<br>world<br>your<br>dictionary<br>6<br>bob<br>d<br>dict<br>dicti<br>yo<br>z<br></pre> </dd><dt style="margin: 0px; padding: 0px; font-weight: bold; font-size: 16px;">鏍蜂緥杈撳嚭</dt><dd style="margin: 12px 0px; padding: 0px;"> <pre style="border: 1px solid #dadada; margin: 0px; padding: 11px; overflow: auto; background-color: #f5f5f5; font-size: 12px; line-height: 1.3em;">bob<br>dict dictionary<br>dict dictionary<br>dictionary<br>youdao your<br>z</pre> </dd></dl></div> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>鐢ㄧ殑鏄痶rie 鏍?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include </span><span style="color: #000000;"><</span><span style="color: #000000;">stdio.h</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">stdlib.h</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">.h</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">vector</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">map</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">queue</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">algorithm</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;"> </span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> std;<br><br></span><span style="color: #008000;">/*</span><span style="color: #008000;"><br>*<br></span><span style="color: #008000;">*/</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> node{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> next[</span><span style="color: #000000;">26</span><span style="color: #000000;">];</span><span style="color: #008000;">//</span><span style="color: #008000;"> 瀵逛簬鏌愪竴灞傝岃█  next銆恑銆?nbsp;涓璱灝辮〃紺鴻灞傛湁鐨勫瓧絎︿簡 next銆恑銆戠殑鍊兼寚鍚戜粬鎵鎸囧悜鐨勭粨鏋?/span><span style="color: #008000;"><br></span><span style="color: #000000;">    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> flag;</span><span style="color: #008000;">//</span><span style="color: #008000;"> 鐢ㄦ潵鏍囪鑺傜偣鏈夋病鏈夎浣跨敤</span><span style="color: #008000;"><br></span><span style="color: #000000;">}trie[</span><span style="color: #000000;">210000</span><span style="color: #000000;">];<br></span><span style="color: #0000ff;">char</span><span style="color: #000000;"> str[</span><span style="color: #000000;">100</span><span style="color: #000000;">];<br></span><span style="color: #0000ff;">char</span><span style="color: #000000;"> ans[</span><span style="color: #000000;">100</span><span style="color: #000000;">];<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> totle</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> insert(){<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> p</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(str[k]){<br>        </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> v</span><span style="color: #000000;">=</span><span style="color: #000000;">str[k]</span><span style="color: #000000;">-</span><span style="color: #000000;">'</span><span style="color: #000000;">a</span><span style="color: #000000;">'</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(trie[p].next[v]</span><span style="color: #000000;">==-</span><span style="color: #000000;">1</span><span style="color: #000000;">)trie[p].next[v]</span><span style="color: #000000;">=</span><span style="color: #000000;">totle</span><span style="color: #000000;">++</span><span style="color: #000000;">; <br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">trie[p].next[v];<br>        k</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    }<br>    trie[p].flag</span><span style="color: #000000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> cur;<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> dfs(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> k,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> p)</span><span style="color: #008000;">//</span><span style="color: #008000;">姝ゆ爲鍦ㄧ粍緇囩殑鏃跺?nbsp;灝辨槸鎸夊瓧鍏告潵鎺掔殑 </span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(cur</span><span style="color: #000000;">>=</span><span style="color: #000000;">8</span><span style="color: #000000;">)</span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(trie[p].flag</span><span style="color: #000000;">!=-</span><span style="color: #000000;">1</span><span style="color: #000000;">){<br>        ans[k]</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(cur</span><span style="color: #000000;">==</span><span style="color: #000000;">0</span><span style="color: #000000;">)printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%s</span><span style="color: #000000;">"</span><span style="color: #000000;">,ans);<br>        </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> printf(</span><span style="color: #000000;">"</span><span style="color: #000000;"> %s</span><span style="color: #000000;">"</span><span style="color: #000000;">,ans);<br>        cur</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    }<br>    </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">26</span><span style="color: #000000;">;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(trie[p].next[i]</span><span style="color: #000000;">!=-</span><span style="color: #000000;">1</span><span style="color: #000000;">){<br>            ans[k]</span><span style="color: #000000;">=</span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">'</span><span style="color: #000000;">a</span><span style="color: #000000;">'</span><span style="color: #000000;">;<br>            dfs(k</span><span style="color: #000000;">+</span><span style="color: #000000;">1</span><span style="color: #000000;">,trie[p].next[i]);<br>        }<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> find(){<br>    cur</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> p</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">,k</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(str[k]</span><span style="color: #000000;">&&</span><span style="color: #000000;">p</span><span style="color: #000000;">!=-</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #008000;">//</span><span style="color: #008000;">姣斿 abc 鎸夋牴寮濮?nbsp;鎵懼埌鍖歸厤 c 絎笁灞傜殑 P </span><span style="color: #008000;"><br></span><span style="color: #000000;">    {<br>        p</span><span style="color: #000000;">=</span><span style="color: #000000;">trie[p].next[str[k]</span><span style="color: #000000;">-</span><span style="color: #000000;">'</span><span style="color: #000000;">a</span><span style="color: #000000;">'</span><span style="color: #000000;">];<br>        ans[k]</span><span style="color: #000000;">=</span><span style="color: #000000;">str[k];<br>        k</span><span style="color: #000000;">++</span><span style="color: #000000;">; <br>    }<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(p</span><span style="color: #000000;">==-</span><span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #008000;">//</span><span style="color: #008000;"> 娌℃湁鍖歸厤鐨?nbsp;閭d箞鐩存帴鎵撳嵃 鎸夐鎰忔潵</span><span style="color: #008000;"><br></span><span style="color: #000000;">    {<br>        printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%s\n</span><span style="color: #000000;">"</span><span style="color: #000000;">,str);<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br>    }<br>    dfs(k,p);</span><span style="color: #008000;">//</span><span style="color: #008000;">緇х畫鎼?nbsp;str[k]涓瓧絎?/span><span style="color: #008000;"><br></span><span style="color: #000000;">    printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">\n</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main() <br>{<br>    freopen(</span><span style="color: #000000;">"</span><span style="color: #000000;">in.txt</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">"</span><span style="color: #000000;">r</span><span style="color: #000000;">"</span><span style="color: #000000;">,stdin);<br>    vector</span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">></span><span style="color: #000000;"> my;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> n;<br>    memset(trie,</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">,</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(trie));<br>    scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">n);<br>    </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;i</span><span style="color: #000000;"><</span><span style="color: #000000;">n;i</span><span style="color: #000000;">++</span><span style="color: #000000;">){<br>        scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%s</span><span style="color: #000000;">"</span><span style="color: #000000;">,str);<br>        insert();<br>    }<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> q;<br>    scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">q);<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(q</span><span style="color: #000000;">--</span><span style="color: #000000;">){<br>        scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%s</span><span style="color: #000000;">"</span><span style="color: #000000;">,str);<br>        find();<br>    }<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}</span></div> <br><br>鍚屾椂榪樼湅鍒頒竴浣嶇墰浜?鐢╯tl 鍐欑殑 閭d釜鐗涘弶 涔熻創涓婁簡 浠ヤ緵鑷繁鍙傝?<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">using</span><span style="color: #000000;"> </span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> std;<br><br></span><span style="color: #0000ff;">string</span><span style="color: #000000;"> ts;<br><br></span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> issub(</span><span style="color: #0000ff;">const</span><span style="color: #000000;"> </span><span style="color: #0000ff;">string</span><span style="color: #000000;"> c)<br>{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (ts.length() </span><span style="color: #000000;">></span><span style="color: #000000;"> c.length()) </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> ts </span><span style="color: #000000;">==</span><span style="color: #000000;"> c.substr(</span><span style="color: #000000;">0</span><span style="color: #000000;">, ts.length());</span><span style="color: #008000;">//</span><span style="color: #008000;">c瀛椾覆涓瀛樺湪ts 榪斿洖true</span><span style="color: #008000;"><br></span><span style="color: #000000;">}<br><br>typedef vector</span><span style="color: #000000;"><</span><span style="color: #0000ff;">string</span><span style="color: #000000;">></span><span style="color: #000000;"> DIC;<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    DIC dict;<br>    </span><span style="color: #0000ff;">string</span><span style="color: #000000;"> str;<br>    size_t dsize, ssize;<br>    cin </span><span style="color: #000000;">>></span><span style="color: #000000;"> dsize;<br>    dict.reserve(dsize);</span><span style="color: #008000;">//</span><span style="color: #008000;">紜繚dict 鐨勫閲忚嚦灝戜負dsize</span><span style="color: #008000;"><br></span><span style="color: #000000;">    </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (size_t i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> dsize; </span><span style="color: #000000;">++</span><span style="color: #000000;">i)<br>    {<br>        cin </span><span style="color: #000000;">>></span><span style="color: #000000;"> str;<br>        dict.push_back(str);<br>    }<br>    std::sort(dict.begin(), dict.end());</span><span style="color: #008000;">//</span><span style="color: #008000;">鎺掑簭</span><span style="color: #008000;"><br></span><span style="color: #000000;">    dict.erase(std::unique(dict.begin(), dict.end()), dict.end());</span><span style="color: #008000;">//</span><span style="color: #008000;">鍘婚櫎閲嶅鐨?/span><span style="color: #008000;"><br></span><span style="color: #000000;">    cin </span><span style="color: #000000;">>></span><span style="color: #000000;"> ssize;<br>    </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (size_t i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> ssize; </span><span style="color: #000000;">++</span><span style="color: #000000;">i)<br>    {<br>        DIC::iterator iter;<br>        cin </span><span style="color: #000000;">>></span><span style="color: #000000;"> ts;<br>        </span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> found </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>        iter </span><span style="color: #000000;">=</span><span style="color: #000000;"> lower_bound(dict.begin(), dict.end(),ts);<br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">姝ゅ嚱鏁板湪msdn 鐨勮В閲婁負 鍦╠ict 涓彃鍏s 鏈灝忕殑浣嶇疆騫剁淮鎸佸簭鍒楁湁搴?/span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(size_t j</span><span style="color: #000000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;j</span><span style="color: #000000;"><</span><span style="color: #000000;">8</span><span style="color: #000000;"> </span><span style="color: #000000;">&&</span><span style="color: #000000;"> iter</span><span style="color: #000000;">!=</span><span style="color: #000000;">dict.end();</span><span style="color: #000000;">++</span><span style="color: #000000;">j,</span><span style="color: #000000;">++</span><span style="color: #000000;">iter)<br>        {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(issub(</span><span style="color: #000000;">*</span><span style="color: #000000;">iter)){<br>                cout</span><span style="color: #000000;"><<*</span><span style="color: #000000;">iter</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;">;<br>                found</span><span style="color: #000000;">=</span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>            }<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">found)<br>            cout </span><span style="color: #000000;"><<</span><span style="color: #000000;"> ts;<br>        cout </span><span style="color: #000000;"><<</span><span style="color: #000000;"> endl;<br>    }<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}<br></span></div> <br> <img src ="http://www.shnenglu.com/397993401/aggbug/116713.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/397993401/" target="_blank">浠樼繑</a> 2010-05-30 00:03 <a href="http://www.shnenglu.com/397993401/archive/2010/05/30/116713.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>hdu 1027 next_permutationhttp://www.shnenglu.com/397993401/archive/2010/05/26/116426.html浠樼繑浠樼繑Wed, 26 May 2010 15:48:00 GMThttp://www.shnenglu.com/397993401/archive/2010/05/26/116426.htmlhttp://www.shnenglu.com/397993401/comments/116426.htmlhttp://www.shnenglu.com/397993401/archive/2010/05/26/116426.html#Feedback0http://www.shnenglu.com/397993401/comments/commentRss/116426.htmlhttp://www.shnenglu.com/397993401/services/trackbacks/116426.htmlnext_permutation  姹傚叏鎺掑垪鐨勭殑涓嬩竴涓?

#include
<iostream>
#include
<algorithm>
#include 
<functional>
using namespace std;
int data[1010];

int main()
{
    
int n,m;
    
while(scanf("%d%d",&n,&m)!=EOF)
    {
        
for(int i = 0; i < n; i ++)
            data[i] 
= i+1;
        sort(data,data
+n);
        m 
--;
        
while(m--)
            next_permutation(data,data
+n);
        
for( i = 0;i<n;i++)
            printf(i 
==0 ?"%d":" %d",data[i]);
        printf(
"\n");

    }
    
return 0;
}



浠樼繑 2010-05-26 23:48 鍙戣〃璇勮
]]>
partial_sort 浜? 閲嶈澆cmp錛堬級榪愮畻絎?/title><link>http://www.shnenglu.com/397993401/archive/2010/05/26/116352.html</link><dc:creator>浠樼繑</dc:creator><author>浠樼繑</author><pubDate>Wed, 26 May 2010 01:14:00 GMT</pubDate><guid>http://www.shnenglu.com/397993401/archive/2010/05/26/116352.html</guid><wfw:comment>http://www.shnenglu.com/397993401/comments/116352.html</wfw:comment><comments>http://www.shnenglu.com/397993401/archive/2010/05/26/116352.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/397993401/comments/commentRss/116352.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/397993401/services/trackbacks/116352.html</trackback:ping><description><![CDATA[<br>鍛靛懙 鐩存帴鐪嬩唬鐮?灝卞彲浠ョ煡閬?C++ 寰堝ソ寰堝己澶?鑷繁鍙桟 鐨勫獎鍝嶅お澶ч <br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include</span><span style="color: #000000;"><</span><span style="color: #000000;">algorithm</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">vector</span><span style="color: #000000;">></span><span style="color: #000000;"><br>#include </span><span style="color: #000000;"><</span><span style="color: #000000;">functional</span><span style="color: #000000;">></span><span style="color: #000000;"><br><br></span><span style="color: #0000ff;">using</span><span style="color: #000000;"> </span><span style="color: #0000ff;">namespace</span><span style="color: #000000;"> std;<br><br></span><span style="color: #0000ff;">const</span><span style="color: #000000;"> </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> maxn </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">3000</span><span style="color: #000000;">+</span><span style="color: #000000;">10</span><span style="color: #000000;">;<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> data[maxn];<br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> node<br>{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> x,y;<br>    </span><span style="color: #0000ff;">char</span><span style="color: #000000;"> name[</span><span style="color: #000000;">20</span><span style="color: #000000;">];<br>} re[maxn];<br></span><span style="color: #008000;">//</span><span style="color: #008000;"> bool cmp(const struct node a,const struct node b)<br></span><span style="color: #008000;">//</span><span style="color: #008000;"> {<br></span><span style="color: #008000;">//</span><span style="color: #008000;">     return (a).x - (b).x;<br></span><span style="color: #008000;">//</span><span style="color: #008000;"> }</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">class</span><span style="color: #000000;"> cmp{<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>    </span><span style="color: #0000ff;">bool</span><span style="color: #000000;"> </span><span style="color: #0000ff;">operator</span><span style="color: #000000;">()(</span><span style="color: #0000ff;">const</span><span style="color: #000000;"> node </span><span style="color: #000000;">&</span><span style="color: #000000;">a,</span><span style="color: #0000ff;">const</span><span style="color: #000000;"> node </span><span style="color: #000000;">&</span><span style="color: #000000;">b)<br>    {<br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">return a.x > b.x;</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(strcmp(a.name,b.name) </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>    }<br>};<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> N,M,i;<br></span><span style="color: #008000;">//</span><span style="color: #008000;">    vector<int > re(maxn*maxn/2);</span><span style="color: #008000;"><br></span><span style="color: #000000;">    <br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">(scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d%d</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">N,</span><span style="color: #000000;">&</span><span style="color: #000000;">M)</span><span style="color: #000000;">!=</span><span style="color: #000000;">EOF)<br>    {<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> N; i </span><span style="color: #000000;">++</span><span style="color: #000000;">)</span><span style="color: #008000;">//</span><span style="color: #008000;"> 杈撳叆n涓暟瀛?/span><span style="color: #008000;"><br></span><span style="color: #000000;">            scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%s</span><span style="color: #000000;">"</span><span style="color: #000000;">,</span><span style="color: #000000;">&</span><span style="color: #000000;">re[i].name);<br>        partial_sort(re,re</span><span style="color: #000000;">+</span><span style="color: #000000;">M,re</span><span style="color: #000000;">+</span><span style="color: #000000;">M,cmp());</span><span style="color: #008000;">//</span><span style="color: #008000;">鎺掑嚭鍓峂澶т釜鏁板瓧</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">for</span><span style="color: #000000;">( i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> M; i </span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(i </span><span style="color: #000000;">==</span><span style="color: #000000;">0</span><span style="color: #000000;">) cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">re[i].name;<br>             </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> cout</span><span style="color: #000000;"><<</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">"</span><span style="color: #000000;"><<</span><span style="color: #000000;">re[i].name;<br></span><span style="color: #008000;">//</span><span style="color: #008000;">         for( i = 0; i < M; i ++)<br></span><span style="color: #008000;">//</span><span style="color: #008000;">             if(i ==0) cout<<re[i].x;<br></span><span style="color: #008000;">//</span><span style="color: #008000;">             else cout<<" "<<re[i].x;</span><span style="color: #008000;"><br></span><span style="color: #000000;">        printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">\n</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>    }<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br></span></div> <br><br><img src ="http://www.shnenglu.com/397993401/aggbug/116352.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/397993401/" target="_blank">浠樼繑</a> 2010-05-26 09:14 <a href="http://www.shnenglu.com/397993401/archive/2010/05/26/116352.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>partial_sort http://www.shnenglu.com/397993401/archive/2010/05/25/116313.html浠樼繑浠樼繑Tue, 25 May 2010 11:00:00 GMThttp://www.shnenglu.com/397993401/archive/2010/05/25/116313.htmlhttp://www.shnenglu.com/397993401/comments/116313.htmlhttp://www.shnenglu.com/397993401/archive/2010/05/25/116313.html#Feedback0http://www.shnenglu.com/397993401/comments/commentRss/116313.htmlhttp://www.shnenglu.com/397993401/services/trackbacks/116313.html緇撳悎涔嬪墠鍦╤du 涓婂仛鐨?涓閬撴帓搴忛 http://www.shnenglu.com/397993401/archive/2010/05/24/116261.html 鐢╯ort 鐨勪唬鐮?br>
榪欓噷鍒欓渶瑕?6MS 鐩告瘮鍏堝墠鐨?00澶氱 鏄劇劧鏄揩浜嗗緢澶?銆傘傘?br>




#include
<iostream>
#include
<algorithm>
#include 
<vector>
#include 
<functional>

using namespace std;

const int maxn = 3000+10;
int data[maxn];
//int re[maxn*maxn/2];
bool cmp(int a,int b)
{
    
return a>b;
}
int main()
{
    
int N,M,ans,i;
    vector
<int > re(maxn*maxn/2);
    
while(scanf("%d%d",&N,&M)!=EOF)
    {
        
for(i = 0; i < N; i ++)
            scanf(
"%d",&data[i]);
        
//sort(data,data+N,cmp);
        ans = 0;
        
for( i = 0;i < N;i++)
            
for(int j = i+1;j<N;j++)
            {
                re[ans] 
= data[i]+data[j];
                
//re.p (data[i]+data[j]);
                ans ++;
            }
        
//for( vector<int>::iterator  it1 = re.begin();  it1 != re.end() ; it1 ++)
        
//        cout<<*it1<<" ";
        
//printf("\n");
        
//partial_sort(re.begin(),re.begin()+M,re.end());//鍥犱負鐢寵浜哸xn*maxn/2 絀洪棿 鎵浠ユ湁寰堝鏄?鍊?nbsp;
        /* 榪欐槸瀵艱嚧鎺掑簭鍚?nbsp;鍑虹幇0 鍊肩殑鍘熷洜*/
        partial_sort(re.begin(),re.begin()
+M,re.begin()+ans,cmp);
        
for( vector<int>::iterator  it = re.begin(); it != re.begin()+M&& it != re.end() ; it ++)
            
if(it ==re.begin()) cout<<*it;
            
else cout<<" "<<*it;
       cout<<endl;// printf(
"\n");
    }
    
return 0;
}



浠樼繑 2010-05-25 19:00 鍙戣〃璇勮
]]>
hdu 1280http://www.shnenglu.com/397993401/archive/2010/05/24/116261.html浠樼繑浠樼繑Mon, 24 May 2010 15:52:00 GMThttp://www.shnenglu.com/397993401/archive/2010/05/24/116261.htmlhttp://www.shnenglu.com/397993401/comments/116261.htmlhttp://www.shnenglu.com/397993401/archive/2010/05/24/116261.html#Feedback0http://www.shnenglu.com/397993401/comments/commentRss/116261.htmlhttp://www.shnenglu.com/397993401/services/trackbacks/116261.html

#include
<iostream>
#include
<algorithm>
using namespace std;

const int maxn = 3000+10;
int data[maxn];
int re[maxn*maxn/2];
bool cmp(int a,int b)
{
    
return a>b;
}
int main()
{
    
int N,M,ans;
    
while(scanf("%d%d",&N,&M)!=EOF)
    {
        
for(int i = 0; i < N; i ++)
            scanf(
"%d",&data[i]);
        
//sort(data,data+N,cmp);
        ans = 0;
        
for( i = 0;i < N;i++)
            
for(int j = i+1;j<N;j++)
            {
                re[ans
++= data[i]+data[j];
            }
        sort(re,re
+N*(N-1)/2,cmp);
        
for( i = 0; i < M; i ++)
            printf(i 
==0 ?"%d":" %d",re[i]);
        printf(
"\n");
    }
    
return 0;
}
鎽樿嚜 hi.baidu.com/topman3758/blog/item/859b18da6222623933fa1cd8.html

鍋欰CM棰樼殑鏃跺欙紝鎺掑簭鏄竴縐嶇粡甯歌鐢ㄥ埌鐨勬搷浣溿傚鏋滄瘡嬈¢兘鑷繁鍐欎釜鍐掓場涔嬬被鐨凮(n^2)鎺掑簭錛屼笉浣嗙▼搴忓鏄撹秴鏃訛紝鑰屼笖嫻垂瀹濊吹鐨勬瘮璧涙椂闂達紝榪樺緢鏈夊彲鑳藉啓閿欍係TL閲岄潰鏈変釜sort鍑芥暟錛屽彲浠ョ洿鎺ュ鏁扮粍鎺掑簭錛屽鏉傚害涓簄*log2(n)銆備嬌鐢ㄨ繖涓嚱鏁幫紝闇瑕佸寘鍚ご鏂囦歡銆?br>    榪欎釜鍑芥暟鍙互浼犱袱涓弬鏁版垨涓変釜鍙傛暟銆傜涓涓弬鏁版槸瑕佹帓搴忕殑鍖洪棿棣栧湴鍧錛岀浜屼釜鍙傛暟鏄尯闂村熬鍦板潃鐨勪笅涓鍦板潃銆備篃灝辨槸璇達紝鎺掑簭鐨勫尯闂存槸[a,b)銆傜畝鍗曟潵璇達紝鏈変竴涓暟緇刬nt a[100]錛岃瀵逛粠a[0]鍒癮[99]鐨勫厓绱犺繘琛屾帓搴忥紝鍙鍐檚ort(a,a+100)灝辮浜嗭紝榛樿鐨勬帓搴忔柟寮忔槸鍗囧簭銆?br>    鎷挎垜鍑虹殑“AC鐨勭瓥鐣?#8221;榪欓鏉ヨ錛岄渶瑕佸鏁扮粍t鐨勭0鍒發en-1鐨勫厓绱犳帓搴忥紝灝卞啓sort(t,t+len);
    瀵瑰悜閲弙鎺掑簭涔熷樊涓嶅錛宻ort(v.begin(),v.end());
    鎺掑簭鐨勬暟鎹被鍨嬩笉灞闄愪簬鏁存暟錛屽彧瑕佹槸瀹氫箟浜嗗皬浜庤繍綆楃殑綾誨瀷閮藉彲浠ワ紝姣斿瀛楃涓茬被string銆?br>    濡傛灉鏄病鏈夊畾涔夊皬浜庤繍綆楃殑鏁版嵁綾誨瀷錛屾垨鑰呮兂鏀瑰彉鎺掑簭鐨勯『搴忥紝灝辮鐢ㄥ埌絎笁鍙傛暟鈥斺旀瘮杈冨嚱鏁般傛瘮杈冨嚱鏁版槸涓涓嚜宸卞畾涔夌殑鍑芥暟錛岃繑鍥炲兼槸bool鍨嬶紝瀹冭瀹氫簡浠涔堟牱鐨勫叧緋繪墠鏄?#8220;灝忎簬”銆傛兂鎶婂垰鎵嶇殑鏁存暟鏁扮粍鎸夐檷搴忔帓鍒楋紝鍙互鍏堝畾涔変竴涓瘮杈冨嚱鏁癱mp
bool cmp(int a,int b)
{
    return a>b;
}
   鎺掑簭鐨勬椂鍊欏氨鍐檚ort(a,a+100,cmp);

   鍋囪鑷繁瀹氫箟浜嗕竴涓粨鏋勪綋node
struct node{
    int a;
    int b;
    double c;
}
   鏈変竴涓猲ode綾誨瀷鐨勬暟緇刵ode arr[100]錛屾兂瀵瑰畠榪涜鎺掑簭錛氬厛鎸塧鍊煎崌搴忔帓鍒楋紝濡傛灉a鍊肩浉鍚岋紝鍐嶆寜b鍊奸檷搴忔帓鍒楋紝濡傛灉b榪樼浉鍚岋紝灝辨寜c闄嶅簭鎺掑垪銆傚氨鍙互鍐欒繖鏍蜂竴涓瘮杈冨嚱鏁幫細

浠ヤ笅鏄唬鐮佺墖孌碉細
bool cmp(node x,node y)
{
     if(x.a!=y.a) return x.a

if(x.b!=y.b) return x.b>y.b;
     return return x.c>y.c;
}   



浠樼繑 2010-05-24 23:52 鍙戣〃璇勮
]]>
国产精品天天影视久久综合网| 国产成人无码精品久久久性色| 久久99精品久久久大学生| 性欧美大战久久久久久久久| 国产精品久久久久久影院| 久久久99精品成人片中文字幕 | 久久精品亚洲AV久久久无码| 综合网日日天干夜夜久久| 久久精品国产亚洲一区二区| 久久亚洲天堂| 久久99久久99小草精品免视看| 狠狠色丁香久久婷婷综合图片| 99久久99这里只有免费的精品| 天堂无码久久综合东京热| 国产一区二区精品久久| 久久精品国产久精国产一老狼| 91秦先生久久久久久久| 国产成人久久精品激情| 精品国产99久久久久久麻豆| 久久青青草原亚洲av无码| 国产精品99久久精品| 亚洲欧美伊人久久综合一区二区 | 久久婷婷五月综合国产尤物app | 久久久久久久97| 久久精品国产欧美日韩99热| 久久久久99精品成人片牛牛影视| 中文字幕亚洲综合久久菠萝蜜| 办公室久久精品| 久久精品www| 久久九九有精品国产23百花影院| 天天爽天天狠久久久综合麻豆| 久久人妻无码中文字幕| 久久久精品无码专区不卡| 国内精品久久久久久久coent| 亚洲午夜精品久久久久久人妖| 国产精品久久自在自线观看| 久久精品国产亚洲AV无码娇色| 无码人妻久久一区二区三区免费丨 | 久久久久AV综合网成人| 99久久做夜夜爱天天做精品| 伊人久久大香线蕉AV一区二区|