锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产日韩久久,亚洲天堂av图片,99精品免费网http://www.shnenglu.com/NicYun/鍩虹鐭ヨ瘑瀛︿範zh-cnSat, 29 Nov 2025 11:59:00 GMTSat, 29 Nov 2025 11:59:00 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>
            欧美激情一区在线| 欧美二区在线观看| 国产精品无码永久免费888| 亚洲无玛一区| 亚洲天堂偷拍| 国产美女高潮久久白浆| 久久精品盗摄| 久久久久久久国产| 91久久黄色| 99精品热视频| 国产人久久人人人人爽| 久久人人超碰| 欧美国产日本在线| 亚洲午夜在线观看| 欧美一二三视频| 激情综合久久| 亚洲人成毛片在线播放女女| 欧美高清视频在线播放| 夜夜精品视频一区二区| 亚洲视频免费| 在线电影院国产精品| 亚洲精品你懂的| 欧美视频精品在线观看| 久久国产精品久久久久久| 久久久久在线| 在线综合亚洲欧美在线视频| 羞羞色国产精品| 亚洲精品乱码久久久久久蜜桃麻豆| 99在线精品观看| 激情视频一区二区三区| 日韩一区二区精品在线观看| 国产亚洲欧美一区| 9人人澡人人爽人人精品| 国产一区二区看久久| 亚洲精品在线三区| 狠狠爱成人网| 亚洲一区二区三区精品动漫| 一区在线播放视频| 亚洲一区二区三区四区在线观看| 影视先锋久久| 亚洲欧美另类久久久精品2019| 亚洲国产成人午夜在线一区| 亚洲一区二区久久| 亚洲裸体在线观看| 久久人人爽人人| 性欧美长视频| 欧美日韩在线观看视频| 欧美高清免费| 欲色影视综合吧| 午夜国产精品视频免费体验区| aaa亚洲精品一二三区| 久久一区二区三区四区| 久久精品二区亚洲w码| 国产精品久久久久久影院8一贰佰 国产精品久久久久久影视 | 日韩视频二区| 最新亚洲一区| 免费高清在线视频一区·| 久久久午夜电影| 国产精品一二三四| 亚洲婷婷在线| 亚洲欧美一区二区三区极速播放 | 欧美精选在线| 亚洲第一区在线| 亚洲高清电影| 久久影院亚洲| 欧美freesex8一10精品| 激情久久五月天| 久久久综合精品| 久久综合一区二区三区| 一区精品久久| 麻豆成人91精品二区三区| 麻豆精品精华液| 在线成人亚洲| 美女爽到呻吟久久久久| 欧美激情精品久久久久久| 18成人免费观看视频| 麻豆成人在线观看| 亚洲茄子视频| 亚洲欧美激情诱惑| 国产精品视频1区| 欧美一区二区在线免费观看| 久久久免费精品| 亚洲国产美女久久久久| 欧美激情精品久久久久久久变态 | 亚洲视频第一页| 欧美视频中文字幕| 亚洲综合色在线| 浪潮色综合久久天堂| 亚洲国产精选| 欧美日韩成人一区| 亚洲欧美日韩在线不卡| 免费在线成人| 亚洲婷婷综合久久一本伊一区| 国产精品视频在线观看| 欧美中文字幕在线| 亚洲国产精品久久久久秋霞不卡| 一区二区三区毛片| 国产一区二区三区免费观看| 久久久久综合| 99综合在线| 久久精品一区二区| 亚洲精品一区在线| 国产欧美另类| 欧美国产日本| 欧美中文字幕第一页| 91久久精品美女高潮| 欧美专区一区二区三区| 亚洲欧洲美洲综合色网| 国产精品日韩在线| 女同性一区二区三区人了人一| 亚洲一区二区三区乱码aⅴ| 欧美福利一区| 久久国产精品毛片| 亚洲无人区一区| 亚洲黄一区二区| 国产亚洲精品一区二区| 欧美日韩精品免费| 另类av导航| 新狼窝色av性久久久久久| 99精品99| 亚洲国产精品成人va在线观看| 久久精品理论片| 亚洲一二三级电影| 亚洲靠逼com| 在线国产日韩| 狠狠色丁香婷婷综合| 国产精品视频专区| 国产精品久久91| 欧美日韩国产成人高清视频| 蜜桃视频一区| 久久久亚洲精品一区二区三区| 亚洲男人av电影| 99精品视频一区| 亚洲乱码国产乱码精品精天堂| 欧美激情aaaa| 欧美mv日韩mv国产网站| 狼人天天伊人久久| 蜜臀久久久99精品久久久久久| 欧美在线地址| 久久国产一区| 欧美一区二区三区视频免费播放| 亚洲专区一区| 亚洲在线观看| 亚洲欧美区自拍先锋| 亚洲欧美激情四射在线日| 中文亚洲欧美| 亚洲视频免费观看| 亚洲一区二区动漫| 亚洲资源在线观看| 欧美一区2区三区4区公司二百| 亚洲自拍三区| 欧美一区在线直播| 久久精品国产成人| 久久一区国产| 亚洲风情亚aⅴ在线发布| 亚洲国产视频一区二区| 亚洲人成欧美中文字幕| av成人免费在线| 一区二区三区国产精华| 亚洲视频在线一区观看| 亚洲欧美春色| 久久久久88色偷偷免费| 玖玖综合伊人| 欧美日韩岛国| 国产精品美女久久久久aⅴ国产馆| 国产精品视频区| 很黄很黄激情成人| 亚洲美女av在线播放| 亚洲一区图片| 久久婷婷国产综合国色天香| 欧美国产视频日韩| 99国产精品久久久久久久| 香港成人在线视频| 久久男人av资源网站| 欧美日韩成人在线视频| 国产欧美日本| 亚洲精品视频在线| 亚洲欧美日韩一区二区三区在线观看 | 久久精品免费| 亚洲国产日韩一级| 午夜精品福利电影| 欧美sm极限捆绑bd| 国产精品自在线| 亚洲人成人77777线观看| 亚洲欧美一级二级三级| 免费成人av| 亚洲一区日韩在线| 欧美国产日韩一二三区| 国产欧美一级| 亚洲精品视频在线观看免费| 欧美一区成人| 亚洲日本理论电影| 久久久久久9| 国产精品久久久久毛片大屁完整版 | 亚洲无限乱码一二三四麻| 免费不卡中文字幕视频| 国产日产精品一区二区三区四区的观看方式 | 欧美怡红院视频| 亚洲精品在线免费| 久久免费视频一区|