锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲综合伊人久久综合,色综合久久久久久久久五月,久久亚洲私人国产精品vAhttp://www.shnenglu.com/397993401/category/13185.html鍦ㄩ剻瑙嗕腑鎴愰暱 璁板綍鎴愰暱鐨勭偣婊?/description>zh-cnSun, 29 May 2011 11:11:36 GMTSun, 29 May 2011 11:11:36 GMT60緙栫▼鐝犵帒銆錛嶃絎洓绔犱範(fàn)棰?/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>絎洓绔犺鐨勬槸浜屽弶鎼滅儲(chǔ)錛岀劧鍚庝範(fàn)棰樹(shù)腑瑕佹眰瀹炵幇浜屽弶鎼滅儲(chǔ)錛屽茍瑕佹眰鍦ㄤ竴涓湁搴忕殑鏁扮粍涓紝鏌ユ壘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 緇х畫璋冪敤 浜屽垎鎼滅儲(chǔ) 鍦?left 鍜?pos –1 涓煡鎵緆ey 錛?濡傛灉鎵懼埌 緇х畫絎簩姝ワ紝濡傛灉娌℃湁絎笁姝?/p> <p>    3 姝ゆ椂鍙互璇存槑 left – pos –1 涓?涓嶅瓨鍦?key 錛岄偅涔堝彲浠ヨ pos 灝辨槸絎竴嬈″嚭鐜扮殑涓嬫爣 </p> <p> </p><pre class="csharpcode"># include<stdio.h> <span id="k4yug2u" class="preproc">#define</span> DEBUG <span id="22gi244" class="kwrd">int</span> bsearch(<span id="i2sumwe" class="kwrd">int</span> array[],<span id="4msesk4" class="kwrd">int</span> &start ,<span id="w6o226q" class="kwrd">int</span> &end ,<span id="kqm2y44" class="kwrd">int</span> key) { <span id="e4aga24" class="kwrd">int</span> i,j; <span id="agkq24s" class="kwrd">int</span> mid; i = start; j = end ; <span id="a2uo444" class="kwrd">while</span>(i <= j) { mid = (i+j)/2; #ifdef DEBUG <span id="wcuwco2" class="rem">// printf("now i j and mid is %d %d %d\n",i,j,mid);</span> <span id="ue2yu2y" class="preproc">#endif</span> <span id="s2swyac" class="kwrd">if</span>(array[mid] == key) <span id="s4e4oey" class="kwrd">return</span> mid; <span id="e4mgqo2" class="kwrd">else</span> <span id="yes2owy" class="kwrd">if</span>(array[mid] < key) i = mid + 1; <span id="qw4cmss" class="kwrd">else</span> j = mid - 1; } start = i,end = mid; <span id="ams44eu" class="kwrd">return</span> -1; } <span id="oasicsi" class="kwrd">int</span> FirstBsearch(<span id="ia2s22o" class="kwrd">int</span> array[],<span id="42yi4ki" class="kwrd">int</span> start ,<span id="wyiu224" class="kwrd">int</span> end ,<span id="eyame2o" class="kwrd">int</span> key) { <span id="2g4cgyo" class="kwrd">int</span> i,j; <span id="w2q242o" class="kwrd">int</span> mid,pos; i = start; j = end ; mid = bsearch(array,start ,end ,key); <span id="yauwyw2" class="kwrd">if</span>(array[mid] == key)<span id="qsk2sgy" class="rem">//濡傛灉鎵懼埌浜?/span> { pos = mid; <span id="mgiko2s" class="kwrd">while</span>( pos != -1 ) { j = pos -1; pos = bsearch(array ,i ,j ,key); } <span id="os24gm4" class="kwrd">return</span> j+1; } <span id="2qya444" class="kwrd">return</span> -1; } <span id="gkeoqw2" class="kwrd">int</span> main() { <span id="2qawqmm" class="kwrd">int</span> data[11] = {1,3,4,7,7,7,7,56,134,134,132487990}; <span id="m4gsuaa" class="kwrd">int</span> key,i; <span id="iak4y24" class="kwrd">int</span> start = 0,end =10; <span id="a24scsq" class="kwrd">for</span>(i = 0 ; i < 4; i ++) { scanf(<span id="eya422y" class="str">"%d"</span>,&key); printf(<span id="ueykccy" class="str">"%d"</span>,FirstBsearch(data,start,end,key)); } <span id="kc24ue2" 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);// 涓嶄細(xì)璋冪敤鏋愭瀯 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);// 涓嶄細(xì)璋冪敤鏋愭瀯 } 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; ">鎵撴嫭鍙鋒槸鍥犱負(fù) - 姣?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>鏈夐亾璧勬牸璧?鏈夐亾鎼滅儲(chǔ)妗?/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="smoueck" 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="22im4wk" 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="seoi2ka" 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;">鍦ㄦ湁閬撴悳绱㈡涓紝褰撹緭鍏ヤ竴涓垨鑰呭涓瓧絎︽椂錛屾悳绱㈡浼?xì)鍑虹庮C竴瀹氭暟閲忕殑鎻愮ず錛屽涓嬪浘鎵紺猴細(xì)<br><img src="http://poj.youdao.com/groups/youdao/suggest.jpg" style="border-width: 0px;"><br><br>鐜板湪緇欎綘N涓崟璇嶅拰涓浜涙煡璇紝璇瘋緭鍑烘彁紺虹粨鏋滐紝涓轟簡(jiǎn)綆鍖栬繖涓棶棰橈紝鍙渶瑕佽緭鍑轟互鏌ヨ璇嶄負(fù)鍓嶇紑鐨勫茍涓旀寜瀛楀吀搴忔帓鍒楃殑鏈鍓嶉潰鐨?涓崟璇嶏紝濡傛灉絎﹀悎瑕佹眰鐨勫崟璇嶄竴涓篃娌℃湁璇峰彧杈撳嚭褰撳墠鏌ヨ璇嶃?/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>鎺ヤ笅鏉琛岋紝姣忚鏈変竴涓崟璇嶏紝琛ㄧず涓涓煡璇㈣瘝錛屾墍鏈夌殑鏌ヨ璇嶄篃閮芥槸鐢卞皬鍐欏瓧姣嶇粍鎴愶紝騫朵笖鎵鏈夌殑鍗曡瘝浠ュ強(qiáng)鏌ヨ鐨勯暱搴﹂兘涓嶈秴榪?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;">瀵逛簬姣忎釜鏌ヨ錛岃緭鍑轟竴琛岋紝鎸夐『搴忚緭鍑?guó)櫙ユ煡璇㈣瘝鐨勬彁绀壕l撴灉錛岀敤絀烘牸闅斿紑銆?/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;涓璱灝辮〃紺鴻灞傛湁鐨勫瓧絎︿簡(jiǎn) 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;">姝ゆ爲(wèi)鍦ㄧ粍緇囩殑鏃跺?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釜鐗涘弶 涔熻創(chuàng)涓婁簡(jiǎn) 浠ヤ緵鑷繁鍙傝?<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 鐨勫閲忚嚦灝戜負(fù)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 鐨勮В閲婁負(fù) 鍦╠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錛堬級(jí)榪愮畻絎?/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++ 寰堝ソ寰堝己澶?鑷繁鍙桟 鐨勫獎(jiǎng)鍝嶅お澶ч <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澶氱 鏄劇劧鏄揩浜?jiǎn)寰堝?銆傘傘?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());//鍥犱負(fù)鐢寵浜?jiǎn)axn*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棰樼殑鏃跺欙紝鎺掑簭鏄竴縐嶇粡甯歌鐢ㄥ埌鐨勬搷浣溿傚鏋滄瘡嬈¢兘鑷繁鍐欎釜鍐掓場(chǎng)涔嬬被鐨凮(n^2)鎺掑簭錛屼笉浣嗙▼搴忓鏄撹秴鏃訛紝鑰屼笖嫻垂瀹濊吹鐨勬瘮璧涙椂闂達(dá)紝榪樺緢鏈夊彲鑳藉啓閿欍係TL閲岄潰鏈変釜sort鍑芥暟錛屽彲浠ョ洿鎺ュ鏁扮粍鎺掑簭錛屽鏉傚害涓簄*log2(n)銆備嬌鐢ㄨ繖涓嚱鏁幫紝闇瑕佸寘鍚ご鏂囦歡銆?br>    榪欎釜鍑芥暟鍙互浼犱袱涓弬鏁版垨涓変釜鍙傛暟銆傜涓涓弬鏁版槸瑕佹帓搴忕殑鍖洪棿棣栧湴鍧錛岀浜屼釜鍙傛暟鏄尯闂村熬鍦板潃鐨勪笅涓鍦板潃銆備篃灝辨槸璇達(dá)紝鎺掑簭鐨勫尯闂存槸[a,b)銆傜畝鍗曟潵璇達(dá)紝鏈変竴涓暟緇刬nt a[100]錛岃瀵逛粠a[0]鍒癮[99]鐨勫厓绱犺繘琛屾帓搴忥紝鍙鍐檚ort(a,a+100)灝辮浜?jiǎn)锛岄粯璁ょ殑鎺掑簭鏂瑰紡鏄崌搴忋?br>    鎷挎垜鍑虹殑“AC鐨勭瓥鐣?#8221;榪欓鏉ヨ錛岄渶瑕佸鏁扮粍t鐨勭0鍒發(fā)en-1鐨勫厓绱犳帓搴忥紝灝卞啓sort(t,t+len);
    瀵瑰悜閲弙鎺掑簭涔熷樊涓嶅錛宻ort(v.begin(),v.end());
    鎺掑簭鐨勬暟鎹被鍨嬩笉灞闄愪簬鏁存暟錛屽彧瑕佹槸瀹氫箟浜?jiǎn)灏忎簬杩惤帡鐨劸c誨瀷閮藉彲浠ワ紝姣斿瀛楃涓茬被string銆?br>    濡傛灉鏄病鏈夊畾涔夊皬浜庤繍綆楃殑鏁版嵁綾誨瀷錛屾垨鑰呮兂鏀瑰彉鎺掑簭鐨勯『搴忥紝灝辮鐢ㄥ埌絎笁鍙傛暟鈥斺旀瘮杈冨嚱鏁般傛瘮杈冨嚱鏁版槸涓涓嚜宸卞畾涔夌殑鍑芥暟錛岃繑鍥炲兼槸bool鍨嬶紝瀹冭瀹氫簡(jiǎn)浠涔堟牱鐨勫叧緋繪墠鏄?#8220;灝忎簬”銆傛兂鎶婂垰鎵嶇殑鏁存暟鏁扮粍鎸夐檷搴忔帓鍒楋紝鍙互鍏堝畾涔変竴涓瘮杈冨嚱鏁癱mp
bool cmp(int a,int b)
{
    return a>b;
}
   鎺掑簭鐨勬椂鍊欏氨鍐檚ort(a,a+100,cmp);

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

浠ヤ笅鏄唬鐮佺墖孌碉細(xì)
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精品综合国产首页| 69国产成人综合久久精品| 伊人久久免费视频| 日本国产精品久久| 亚洲av成人无码久久精品| 久久精品国产99国产精品澳门 | 亚洲国产小视频精品久久久三级| 丰满少妇人妻久久久久久4| 亚洲精品WWW久久久久久| 久久精品a亚洲国产v高清不卡| 天天久久狠狠色综合| 伊人久久大香线蕉av一区| 韩国无遮挡三级久久| 狠狠色婷婷久久综合频道日韩 | 女人香蕉久久**毛片精品| 久久午夜夜伦鲁鲁片免费无码影视 | 亚洲综合婷婷久久| 国产精品99久久免费观看| 午夜精品久久久久久| 国内精品久久久久久久久| 久久精品一本到99热免费| 欧美久久综合九色综合| 94久久国产乱子伦精品免费 | 无码国内精品久久人妻麻豆按摩 | 一本久久精品一区二区| 国产三级精品久久| 久久亚洲精精品中文字幕| 久久久久久精品久久久久| 国产精品乱码久久久久久软件| 国产AV影片久久久久久| 中文字幕亚洲综合久久2| 99久久国语露脸精品国产| 无码超乳爆乳中文字幕久久| 久久91精品国产91久| 国产精品99久久久久久猫咪| 国产精品欧美亚洲韩国日本久久| 久久久久久久99精品免费观看| 国产精品99久久99久久久| 国产亚洲色婷婷久久99精品| 久久91精品国产91久久户| 久久99国产综合精品女同|