锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美一区二区精品,黄色成人av网,国产欧美亚洲视频http://www.shnenglu.com/NicYun/category/9721.html鍩虹鐭ヨ瘑瀛︿範zh-cnFri, 13 Mar 2009 04:15:48 GMTFri, 13 Mar 2009 04:15:48 GMT60鏍戠姸鏁扮粍http://www.shnenglu.com/NicYun/archive/2009/03/13/76415.htmlNicYunNicYunFri, 13 Mar 2009 03:30:00 GMThttp://www.shnenglu.com/NicYun/archive/2009/03/13/76415.htmlhttp://www.shnenglu.com/NicYun/comments/76415.htmlhttp://www.shnenglu.com/NicYun/archive/2009/03/13/76415.html#Feedback0http://www.shnenglu.com/NicYun/comments/commentRss/76415.htmlhttp://www.shnenglu.com/NicYun/services/trackbacks/76415.htmlclass TreeArray
{
    
int c[1100000]; // element id must start at 1
    int size;
    
int lowbit(int x)
    {
        
return x & (-x);
    }
public:
    
void init(int s = N - 1)
    {
        size 
= s;
        memset(c,
0,size * sizeof(c[0]));
    }
    
int sum(int n) // 鍓峮涓暟鐨勫拰錛屽寘鎷琻
    {
        
int s = 0;
        
while (n > 0)
        {
            s 
+= c[n];
            n 
-= lowbit(n);
        }
        
return s;
    }
    
void plus(int p,int x) // add x to the element at position p
    {
        
while (p <= size)
        {
            c[p] 
+= x;
            p 
+= lowbit(p);
        }
    }
};



NicYun 2009-03-13 11:30 鍙戣〃璇勮
]]>
java 鍒嗘暟綾?/title><link>http://www.shnenglu.com/NicYun/archive/2009/03/08/75932.html</link><dc:creator>NicYun</dc:creator><author>NicYun</author><pubDate>Sun, 08 Mar 2009 13:02:00 GMT</pubDate><guid>http://www.shnenglu.com/NicYun/archive/2009/03/08/75932.html</guid><wfw:comment>http://www.shnenglu.com/NicYun/comments/75932.html</wfw:comment><comments>http://www.shnenglu.com/NicYun/archive/2009/03/08/75932.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/NicYun/comments/commentRss/75932.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/NicYun/services/trackbacks/75932.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: #0000ff;">class</span><span style="color: #000000;"> Fraction<br>{<br>    BigInteger up, down;<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction (Fraction f)<br>    {<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.up;<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.down;<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction(String s)<br>    {<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(s);<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">1</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction(BigInteger a, BigInteger b)<br>    {<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> a;<br>        </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> b;<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BigInteger getUp()<br>    {<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up;<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BigInteger getDown()<br>    {<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down;<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction subtract(Fraction f)<br>    {<br>        BigInteger save1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up.multiply (f.down);<br>        BigInteger save2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.up.multiply(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down);<br>        Fraction tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Fraction(save1.subtract (save2), f.down .multiply ( </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down));<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> simplex(tmp);<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction add(Fraction f)<br>    {<br>        Fraction tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Fraction (</span><span style="color: #000000;">"</span><span style="color: #000000;">0</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>        tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> tmp.subtract(f);<br>        Fraction ans </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Fraction (</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.subtract(tmp));<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> ans;<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction multiply(Fraction f)<br>    {<br>        Fraction tmp;<br>        tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Fraction(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up.multiply (f.up), </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down.multiply (f.down));<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (tmp.down.compareTo(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">0</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;">1</span><span style="color: #000000;">)<br>        {<br>            tmp.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> tmp.down.multiply (</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">-1</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br>            tmp.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> tmp.up.multiply (</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">-1</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br>        }<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> simplex(tmp);<br>    }<br>    </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Fraction divide(Fraction f)<br>    {<br>        Fraction tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>        tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Fraction(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.up.multiply (f.down), </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.down.multiply (f.up));<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (tmp.down.compareTo(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">0</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;">1</span><span style="color: #000000;">)<br>        {<br>            tmp.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> tmp.down.multiply (</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">-1</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br>            tmp.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> tmp.up.multiply (</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">-1</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br>        }<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> simplex(tmp);<br>    }<br>    BigInteger gcd(BigInteger a, BigInteger b)<br>    {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (b.compareTo(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">0</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;">0</span><span style="color: #000000;">)<br>            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> a;<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> gcd(b, a.remainder (b));<br>    }<br>    Fraction simplex(Fraction f)<br>    {<br>        BigInteger tmp </span><span style="color: #000000;">=</span><span style="color: #000000;"> gcd(f.up.abs(), f.down.abs ());<br>        f.up </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.up.divide (tmp);<br>        f.down </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.down.divide (tmp);<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> f;<br>    }<br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> print()<br>    {<br>        BigInteger a, b, c;<br>        a </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.getUp ();<br>        b </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.getDown();<br>        c </span><span style="color: #000000;">=</span><span style="color: #000000;"> gcd(a.abs(), b.abs());<br>        a </span><span style="color: #000000;">=</span><span style="color: #000000;"> a.divide (c);<br>        b </span><span style="color: #000000;">=</span><span style="color: #000000;"> b.divide (c);<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (b.compareTo (</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BigInteger(</span><span style="color: #000000;">"</span><span style="color: #000000;">1</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;">0</span><span style="color: #000000;">)<br>            System.out.println(a);<br>        </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>            System.out.println (a </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;"> b);<br>    }<br>}</span></div> <br><img src ="http://www.shnenglu.com/NicYun/aggbug/75932.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/NicYun/" target="_blank">NicYun</a> 2009-03-08 21:02 <a href="http://www.shnenglu.com/NicYun/archive/2009/03/08/75932.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>綰挎鏍?/title><link>http://www.shnenglu.com/NicYun/archive/2008/08/05/58037.html</link><dc:creator>NicYun</dc:creator><author>NicYun</author><pubDate>Tue, 05 Aug 2008 01:24:00 GMT</pubDate><guid>http://www.shnenglu.com/NicYun/archive/2008/08/05/58037.html</guid><wfw:comment>http://www.shnenglu.com/NicYun/comments/58037.html</wfw:comment><comments>http://www.shnenglu.com/NicYun/archive/2008/08/05/58037.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/NicYun/comments/commentRss/58037.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/NicYun/services/trackbacks/58037.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"><span style="color: #000000;">#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;">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: #0000ff;">const</span><span style="color: #000000;"> </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> SIZE </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">10010</span><span style="color: #000000;">;<br><br></span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> node </span><span style="color: #008000;">//</span><span style="color: #008000;"> the node of line tree</span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i,j; </span><span style="color: #008000;">//</span><span style="color: #008000;"> 鍖洪棿鑼冨洿</span><span style="color: #008000;"><br></span><span style="color: #000000;">    node </span><span style="color: #000000;">*</span><span style="color: #000000;"> lson;<br>    node </span><span style="color: #000000;">*</span><span style="color: #000000;"> rson;<br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> count; </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;">int</span><span style="color: #000000;"> m; </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;">int</span><span style="color: #000000;"> line; </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;">int</span><span style="color: #000000;"> lbd,rbd; </span><span style="color: #008000;">//</span><span style="color: #008000;"> 鐢ㄦ潵璁$畻榪炵畫孌墊暟</span><span style="color: #008000;"><br></span><span style="color: #000000;">    node(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r)<br>    {<br>        i </span><span style="color: #000000;">=</span><span style="color: #000000;"> l,j </span><span style="color: #000000;">=</span><span style="color: #000000;"> r;<br>        count </span><span style="color: #000000;">=</span><span style="color: #000000;"> m </span><span style="color: #000000;">=</span><span style="color: #000000;"> line </span><span style="color: #000000;">=</span><span style="color: #000000;"> lbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> rbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        lson </span><span style="color: #000000;">=</span><span style="color: #000000;"> rson </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br>    }<br>};<br></span><span style="color: #0000ff;">class</span><span style="color: #000000;"> LineTree<br>{<br>    node </span><span style="color: #000000;">*</span><span style="color: #000000;"> head;<br>    </span><span style="color: #008000;">/*</span><span style="color: #008000;"> 浠ヤ笅鍑芥暟鍐呴儴浣跨敤,鍙笉鐢ㄨ冭檻 </span><span style="color: #008000;">*/</span><span style="color: #000000;"><br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> init(node </span><span style="color: #000000;">*</span><span style="color: #000000;"> pnode </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL)<br>    {<br>        head </span><span style="color: #000000;">=</span><span style="color: #000000;"> pnode;<br>    }<br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> updateM()<br>    {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">count </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #008000;">//</span><span style="color: #008000;"> 琚鐩栨弧</span><span style="color: #008000;"><br></span><span style="color: #000000;">            head</span><span style="color: #000000;">-></span><span style="color: #000000;">m </span><span style="color: #000000;">=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">j </span><span style="color: #000000;">-</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">i;<br>        </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">j </span><span style="color: #000000;">-</span><span style="color: #000000;"> head</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;">1</span><span style="color: #000000;">) </span><span style="color: #008000;">//</span><span style="color: #008000;"> 璇ヨ妭鐐逛負鍙惰妭鐐?/span><span style="color: #008000;"><br></span><span style="color: #000000;">            head</span><span style="color: #000000;">-></span><span style="color: #000000;">m </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;">else</span><span style="color: #000000;">    </span><span style="color: #008000;">//</span><span style="color: #008000;"> 鍏朵粬鍐呴儴鑺傜偣鐨勬儏鍐?/span><span style="color: #008000;"><br></span><span style="color: #000000;">            head</span><span style="color: #000000;">-></span><span style="color: #000000;">m </span><span style="color: #000000;">=</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson)</span><span style="color: #000000;">-></span><span style="color: #000000;">m </span><span style="color: #000000;">+</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson)</span><span style="color: #000000;">-></span><span style="color: #000000;">m;<br>    }<br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> updateLine()<br>    {<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">count </span><span style="color: #000000;">></span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>            head</span><span style="color: #000000;">-></span><span style="color: #000000;">lbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">rbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">line </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">j </span><span style="color: #000000;">-</span><span style="color: #000000;"> head</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;">1</span><span style="color: #000000;">)<br>            head</span><span style="color: #000000;">-></span><span style="color: #000000;">lbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">rbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">line </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;">else</span><span style="color: #000000;"><br>        {<br>            head</span><span style="color: #000000;">-></span><span style="color: #000000;">lbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson)</span><span style="color: #000000;">-></span><span style="color: #000000;">lbd;<br>            head</span><span style="color: #000000;">-></span><span style="color: #000000;">rbd </span><span style="color: #000000;">=</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson)</span><span style="color: #000000;">-></span><span style="color: #000000;">rbd;<br>            head</span><span style="color: #000000;">-></span><span style="color: #000000;">line </span><span style="color: #000000;">=</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson)</span><span style="color: #000000;">-></span><span style="color: #000000;">line </span><span style="color: #000000;">+</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson)</span><span style="color: #000000;">-></span><span style="color: #000000;">line </span><span style="color: #000000;">-</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson)</span><span style="color: #000000;">-></span><span style="color: #000000;">rbd </span><span style="color: #000000;">*</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson)</span><span style="color: #000000;">-></span><span style="color: #000000;">lbd;<br>        }<br>    }<br></span><span style="color: #0000ff;">public</span><span style="color: #000000;">:<br>    LineTree();<br>    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> clear(); </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;">void</span><span style="color: #000000;"> build(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r); </span><span style="color: #008000;">//</span><span style="color: #008000;"> 寤虹珛綰挎鏍?鍖洪棿[l,r];</span><span style="color: #008000;"><br></span><span style="color: #000000;">    </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> insert(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r); </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;">void</span><span style="color: #000000;"> del(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r); </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;">int</span><span style="color: #000000;"> GetM(); </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;">int</span><span style="color: #000000;"> GetLine(); </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;">int</span><span style="color: #000000;"> GetCov(); </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: #000000;">~</span><span style="color: #000000;">LineTree();<br>};<br>LineTree::LineTree()<br>{<br>    head </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> LineTree::clear() </span><span style="color: #008000;">//</span><span style="color: #008000;"> 娓呯┖綰挎鏁?/span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (head </span><span style="color: #000000;">==</span><span style="color: #000000;"> NULL)<br>        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br>    LineTree temp;<br>    temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson);<br>    temp.clear();<br>    temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson);<br>    temp.clear();<br>    delete head;<br>    head </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> LineTree::build(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r) </span><span style="color: #008000;">//</span><span style="color: #008000;"> 寤虹珛綰挎鏍?鍖洪棿[l,r]</span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    head </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> node(l,r);<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (r </span><span style="color: #000000;">-</span><span style="color: #000000;"> l </span><span style="color: #000000;">></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;"> k </span><span style="color: #000000;">=</span><span style="color: #000000;"> (l </span><span style="color: #000000;">+</span><span style="color: #000000;"> r) </span><span style="color: #000000;">/</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;">;<br>        LineTree temp;<br>        temp.build(l,k);<br>        head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.head;<br>        temp.init();<br>        temp.build(k,r);<br>        head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.head;<br>    }<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> LineTree::insert(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r) </span><span style="color: #008000;">//</span><span style="color: #008000;"> 鎻掑叆涓鏉$嚎孌?/span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (l </span><span style="color: #000000;"><=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">i </span><span style="color: #000000;">&&</span><span style="color: #000000;"> r </span><span style="color: #000000;">>=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">j)<br>        (head</span><span style="color: #000000;">-></span><span style="color: #000000;">count)</span><span style="color: #000000;">++</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>    {<br>        LineTree temp;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (l </span><span style="color: #000000;"><</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">head</span><span style="color: #000000;">-></span><span style="color: #000000;">j)</span><span style="color: #000000;">/</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>        {<br>            temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson);<br>            temp.insert(l,r);<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (r </span><span style="color: #000000;">></span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">head</span><span style="color: #000000;">-></span><span style="color: #000000;">j)</span><span style="color: #000000;">/</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>        {<br>            temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson);<br>            temp.insert(l,r);<br>        }<br>    }<br>    updateM();<br>    updateLine();<br>}<br></span><span style="color: #0000ff;">void</span><span style="color: #000000;"> LineTree::del(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> l,</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> r) </span><span style="color: #008000;">//</span><span style="color: #008000;"> 鍒犻櫎涓鏉$嚎孌?/span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (l </span><span style="color: #000000;"><=</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">i </span><span style="color: #000000;">&&</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">j </span><span style="color: #000000;"><=</span><span style="color: #000000;"> r)<br>        (head</span><span style="color: #000000;">-></span><span style="color: #000000;">count)</span><span style="color: #000000;">--</span><span style="color: #000000;">;<br>    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>    {<br>        LineTree temp;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (l </span><span style="color: #000000;"><</span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">head</span><span style="color: #000000;">-></span><span style="color: #000000;">j)</span><span style="color: #000000;">/</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>        {<br>            temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">lson);<br>            temp.del(l,r);<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (r </span><span style="color: #000000;">></span><span style="color: #000000;"> (head</span><span style="color: #000000;">-></span><span style="color: #000000;">i</span><span style="color: #000000;">+</span><span style="color: #000000;">head</span><span style="color: #000000;">-></span><span style="color: #000000;">j)</span><span style="color: #000000;">/</span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>        {<br>            temp.init(head</span><span style="color: #000000;">-></span><span style="color: #000000;">rson);<br>            temp.del(l,r);<br>        }<br>    }<br>    updateM();<br>    updateLine();<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> LineTree::GetM() </span><span style="color: #008000;">//</span><span style="color: #008000;"> 嫻嬪害</span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">m;<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> LineTree::GetLine() </span><span style="color: #008000;">//</span><span style="color: #008000;"> 榪炵畫孌墊暟</span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">line;<br>}<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> LineTree::GetCov() </span><span style="color: #008000;">//</span><span style="color: #008000;"> 瑕嗙洊綰挎鏁?/span><span style="color: #008000;"><br></span><span style="color: #000000;">{<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> head</span><span style="color: #000000;">-></span><span style="color: #000000;">count;<br>}<br>LineTree::</span><span style="color: #000000;">~</span><span style="color: #000000;">LineTree()<br>{<br>    </span><span style="color: #0000ff;">this</span><span style="color: #000000;">-></span><span style="color: #000000;">clear();<br>}<br><br></span></div><img src ="http://www.shnenglu.com/NicYun/aggbug/58037.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/NicYun/" target="_blank">NicYun</a> 2008-08-05 09:24 <a href="http://www.shnenglu.com/NicYun/archive/2008/08/05/58037.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏈灝忓爢鍜屾渶澶у爢http://www.shnenglu.com/NicYun/archive/2008/08/04/57934.htmlNicYunNicYunMon, 04 Aug 2008 02:29:00 GMThttp://www.shnenglu.com/NicYun/archive/2008/08/04/57934.htmlhttp://www.shnenglu.com/NicYun/comments/57934.htmlhttp://www.shnenglu.com/NicYun/archive/2008/08/04/57934.html#Feedback0http://www.shnenglu.com/NicYun/comments/commentRss/57934.htmlhttp://www.shnenglu.com/NicYun/services/trackbacks/57934.html#include <iostream>
#include 
<string>
#include 
<stdio.h>
using namespace std;

#define SIZE  500000

void swap(int &a,int &b)
{
    
int temp = a;
    a 
= b;
    b 
= temp;
}

class Heap
{
    
int size;
    
int heap[SIZE];
public:
    
virtual bool cmp(int a,int b) = 0;
private:
    inline 
int fathter(int p)
    {
        
return p / 2;
    }
    inline 
int LeftSon(int p)
    {
        
int son = 2 * p;
        
if (son > size)
            
return 0;
        
return son;
    }
    inline 
int RightSon(int p)
    {
        
int son = 2 * p + 1;
        
if (son > size)
            
return 0;
        
return son;
    }
    
int ShiftUp(int p)
    {
        
if (p == 1)
            
return p;
        
if (cmp(heap[p],heap[fathter(p)]))
        {
            swap(heap[p],heap[fathter(p)]);
            
return fathter(p);
        }
        
return p;
    }
    
int ShiftDown(int p)
    {
        
int lagest = p;

        
if ((LeftSon(p)) && (cmp(heap[LeftSon(p)],heap[lagest])))
            lagest 
= LeftSon(p);
        
if ((RightSon(p)) && (cmp(heap[RightSon(p)],heap[lagest])))
            lagest 
= RightSon(p);
        
if (lagest != p)
            swap(heap[lagest],heap[p]);
        
return lagest;
    }
public:
    Heap() { size 
= 0; }
    
int insert(int n);
    
void del(int p);
    
void DelHead();
    
int head();
    
void init();
    
bool IsEempty();
};
int Heap::insert(int n)
{
    size
++;
    heap[size] 
= n;
    
int where = size;
    
int p;
    
while (((p = ShiftUp(where)) != where))
    {
        where 
= p;
        
continue;
    }
    
return where;
}
void Heap::del(int p)
{
    heap[p] 
= heap[size];
    size
--;
    
int where;
    
while (((where = ShiftDown(p)) != p))
    {
        p 
= where;
        
continue;
    }
}
void Heap::DelHead()
{
    del(
1);
}
int Heap::head()
{
    
if (size == 0)
        
return -1;
    
return heap[1];
}
void Heap::init()
{
    size 
= 0;
}
bool Heap::IsEempty()
{
    
if (size == 0)
        
return 1;
    
else
        
return 0;
}

class MaxHeap : public Heap
{
    
bool cmp(int a,int b)
    {
        
return a > b;
    }
};

class MinHeap : public Heap
{
    
bool cmp(int a,int b)
    {
        
return a < b;
    }
};

int main()
{
    
return 0;
}


NicYun 2008-08-04 10:29 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美不卡福利| 亚洲国产国产亚洲一二三| 亚洲精品中文字| 欧美福利视频在线观看| 亚洲精品1区2区| 亚洲第一精品福利| 欧美精品久久久久久| 99国产精品国产精品久久 | 国产丝袜一区二区三区| 欧美在线亚洲在线| 久久精品夜色噜噜亚洲a∨ | 欧美日韩精品在线| 亚洲一区二区三区777| 日韩视频不卡| 国产精品永久免费| 久久性色av| 欧美激情在线播放| 亚洲欧美日韩综合一区| 欧美专区在线观看| 亚洲美女在线一区| 午夜精品久久久久影视| 亚洲第一网站| 在线亚洲观看| 亚洲大片精品永久免费| 亚洲精品小视频在线观看| 国产精品午夜在线观看| 免费在线亚洲欧美| 欧美日韩中文在线| 久久久久久久综合狠狠综合| 免费欧美网站| 亚洲综合精品四区| 老司机精品导航| 亚洲欧美国产高清| 美女任你摸久久| 亚洲欧美三级伦理| 欧美激情2020午夜免费观看| 久久精品夜色噜噜亚洲a∨| 欧美大片免费久久精品三p| 欧美在线视屏| 欧美日本在线播放| 麻豆成人小视频| 国产精品高潮呻吟| 亚洲大片av| 国产亚洲a∨片在线观看| 亚洲人被黑人高潮完整版| 国产亚洲在线观看| 一区二区三区 在线观看视频 | 欧美三级在线| 欧美大片免费观看在线观看网站推荐| 欧美午夜激情在线| 91久久精品日日躁夜夜躁国产| 国产精品系列在线| 一区二区欧美日韩| 夜夜狂射影院欧美极品| 狂野欧美一区| 蜜乳av另类精品一区二区| 国产毛片一区| 亚洲在线视频观看| 亚洲一区网站| 欧美日韩高清在线观看| 91久久精品一区二区别| 亚洲人被黑人高潮完整版| 久久精品99无色码中文字幕| 久久精品国产第一区二区三区最新章节 | 亚洲性感激情| 一区二区三区日韩欧美| 欧美激情第4页| 欧美国产精品久久| 亚洲国产精品美女| 久久国产精品久久精品国产 | 亚洲免费电影在线观看| 另类尿喷潮videofree| 欧美sm极限捆绑bd| 亚洲第一色在线| 蜜臀久久99精品久久久画质超高清 | 国产一区二区三区四区| 亚洲欧美日韩网| 香蕉成人伊视频在线观看| 国产精品美女一区二区在线观看| 中文日韩在线视频| 久久黄色网页| 红桃视频一区| 免费高清在线一区| 亚洲激情社区| 亚洲在线播放电影| 国产精品中文在线| 久久不射中文字幕| 欧美成人午夜视频| 亚洲一区二区三区免费在线观看| 国产精品久久久久久一区二区三区 | 日韩亚洲精品视频| 亚洲欧美精品中文字幕在线| 国产日韩精品久久久| 久久免费视频在线| 亚洲激情中文1区| 亚洲综合日本| 精品福利电影| 欧美日韩123| 久久国产福利| 另类综合日韩欧美亚洲| 夜夜嗨av一区二区三区中文字幕| 国产精品久久中文| 六十路精品视频| 这里只有精品电影| 亚洲成人在线免费| 久久另类ts人妖一区二区| 91久久香蕉国产日韩欧美9色| 亚洲欧美日产图| 尤物99国产成人精品视频| 欧美日韩一二三区| 久久se精品一区二区| 日韩一级精品| 欧美电影免费观看高清| 性欧美1819性猛交| 一本大道久久a久久综合婷婷| 国产欧美日韩综合一区在线播放| 欧美va亚洲va国产综合| 亚洲欧美在线高清| 亚洲精选大片| 欧美黄污视频| 久久美女艺术照精彩视频福利播放| 亚洲黄色影院| 国内精品福利| 国产精品视频不卡| 欧美伦理91i| 美女精品在线| 久久久久se| 欧美在线观看一区| 亚洲免费影院| 99精品免费网| 亚洲人午夜精品| 欧美成人高清| 久久亚洲春色中文字幕| 香蕉av福利精品导航| 亚洲人成在线观看| 亚洲黄色影院| 91久久久久久| 亚洲国产欧美一区二区三区丁香婷| 国产午夜精品全部视频播放| 国产精品a级| 国产精品观看| 欧美三级小说| 国产精品久久久久久久久久免费 | 国产日韩在线视频| 国产伦精品一区二区三区高清版| 欧美日韩国产区一| 欧美激情一区二区在线| 欧美精品日韩三级| 欧美人成免费网站| 欧美午夜a级限制福利片| 欧美性猛交视频| 国产精品日本欧美一区二区三区| 国产精品人人做人人爽人人添| 国产精品久久午夜| 国产视频一区免费看| 国产在线日韩| 在线观看日韩一区| 亚洲人成网站影音先锋播放| 亚洲免费播放| 亚洲一区在线直播| 欧美伊人久久久久久久久影院| 久久国产精品99国产| 久久综合狠狠综合久久综青草| 美女图片一区二区| 欧美激情麻豆| av成人激情| 性欧美长视频| 欧美r片在线| 欧美偷拍另类| 国产欧美一区二区精品仙草咪| 国内精品嫩模av私拍在线观看 | 亚洲国产高清自拍| 日韩一区二区免费高清| 亚洲欧美另类综合偷拍| 久久免费视频在线观看| 亚洲电影在线免费观看| 99ri日韩精品视频| 久久久.com| 欧美日本韩国一区| 国产一区二区三区电影在线观看 | 国产精品免费看久久久香蕉| 国产一区视频在线看| 亚洲韩国一区二区三区| 亚洲欧美日本日韩| 欧美大片18| 亚洲欧美国产精品桃花| 欧美国产专区| 国内精品久久国产| 中文精品99久久国产香蕉| 久久久综合精品| 一本色道**综合亚洲精品蜜桃冫| 久久成年人视频| 欧美日韩国产综合新一区| 一区二区三区亚洲| 午夜精品亚洲| 亚洲人午夜精品免费| 久久久久国产精品人| 国产精品自拍小视频| 99re热精品| 欧美成人精品福利|