﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-ACM___________________________</title><link>http://www.cppblog.com/MiYu/</link><description>                             ______________白白の屋</description><language>zh-cn</language><lastBuildDate>Wed, 22 Apr 2026 05:04:00 GMT</lastBuildDate><pubDate>Wed, 22 Apr 2026 05:04:00 GMT</pubDate><ttl>60</ttl><item><title>博客搬家了......http://orz.miyuoo.com</title><link>http://www.cppblog.com/MiYu/archive/2010/12/19/136956.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sun, 19 Dec 2010 11:45:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/12/19/136956.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/136956.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/12/19/136956.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/136956.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/136956.html</trackback:ping><description><![CDATA[终于有自己的空间了, &nbsp;博客搬到&nbsp;<a href="http://orz.miyuoo.com/">http://orz.miyuoo.com</a>&nbsp;了 ^_^<img src ="http://www.cppblog.com/MiYu/aggbug/136956.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-12-19 19:45 <a href="http://www.cppblog.com/MiYu/archive/2010/12/19/136956.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 3468 HDOJ 3468 A Simple Problem with Integers ACM 3468 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/11/16/133824.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Tue, 16 Nov 2010 13:28:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/16/133824.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133824.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/16/133824.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133824.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133824.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MiYu原创, 转帖请注明 : 转载自&nbsp;______________白白の屋&nbsp;&nbsp;&nbsp;&nbsp;代码&lt;pre&nbsp;lang="cpp"&nbsp;line="1"&gt;/*Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.comMy&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nb...&nbsp;&nbsp;<a href='http://www.cppblog.com/MiYu/archive/2010/11/16/133824.html'>阅读全文</a><img src ="http://www.cppblog.com/MiYu/aggbug/133824.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-16 21:28 <a href="http://www.cppblog.com/MiYu/archive/2010/11/16/133824.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 2574 HDOJ 2574 Hdu Girls' Day ACM 2574 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/11/16/133819.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Tue, 16 Nov 2010 11:43:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/16/133819.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133819.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/16/133819.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133819.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133819.html</trackback:ping><description><![CDATA[<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">因为 大于 1 &lt;&lt; 16 的和数都能用 1 -- 1&lt;&lt;16 之间的素数表示, 不能表示的肯定是 素数了, 所以处理 1-- 1&lt;&lt;16之间的素数就可以了.</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">不过貌似这题的数据很弱没有大于 1 &lt;&lt; 16 的素数.&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;<span  style="font-family: 'Courier New'; font-size: 15.6px; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_3f0fa3d1-d84d-4bf7-bec7-063de6410455" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; ">代码</span></span></p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><div id="cnblogs_code_open_3f0fa3d1-d84d-4bf7-bec7-063de6410455"><div><div>#include &lt;iostream&gt;</div><div>#include &lt;algorithm&gt;</div><div>#include &lt;string&gt;</div><div>#include &lt;set&gt;</div><div>#include &lt;map&gt;</div><div>#include &lt;utility&gt;</div><div>#include &lt;queue&gt;</div><div>#include &lt;stack&gt;</div><div>#include &lt;vector&gt;</div><div>#include &lt;cstdio&gt;</div><div>#include &lt;cstdlib&gt;</div><div>#include &lt;cstring&gt;</div><div>#include &lt;cmath&gt;</div><div>using namespace std;</div><div><br></div><div>struct type</div><div>{</div><div>&nbsp;&nbsp;char name[30];</div><div>&nbsp;&nbsp;int num;</div><div>}a[1005];</div><div><br></div><div>const int MAX_PRIME = &nbsp;1 &lt;&lt; 16;</div><div># define PRIME_NUM 35000</div><div>int Primes[PRIME_NUM + 10] ;</div><div>bool &nbsp;PrimeBuffer[MAX_PRIME];</div><div>int _Count = 0;</div><div>int GetPrimes ()</div><div>{</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>int i, j ;</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span></div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>for (i = 2 ; i &lt; MAX_PRIME ; i++)</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>{</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">		</span>if (PrimeBuffer[i] == 0)</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">			</span>Primes[_Count++] = i ;</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">		</span>for (j = 0 ; j &lt; _Count &amp;&amp; i * Primes[j] &lt;= MAX_PRIME ; j++)</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">		</span>{</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">			</span>PrimeBuffer[i * Primes[j]] = 1 ;</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">		</span>&nbsp;<span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>if (i % Primes[j] == 0) break ;</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">		</span>}</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>}</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>free (PrimeBuffer) ;</div><div><span class="Apple-tab-span" style="font-family: 'Courier New'; white-space: pre; ">	</span>return _Count ;</div><div>}</div><div>inline bool scan_d(int &amp;num) &nbsp;//整数输入</div><div>{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char in;bool IsN=false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;in=getchar();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(in==EOF) return false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(in!='-'&amp;&amp;(in&lt;'0'||in&gt;'9')) in=getchar();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(in=='-'){ IsN=true;num=0;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else num=in-'0';</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(in=getchar(),in&gt;='0'&amp;&amp;in&lt;='9'){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;num*=10,num+=in-'0';</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(IsN) num=-num;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return true;</div><div>}</div><div>int main ()</div><div>{</div><div>&nbsp;&nbsp; &nbsp;int T;</div><div>&nbsp;&nbsp; &nbsp;GetPrimes ();</div><div>&nbsp;&nbsp; &nbsp;scan_d(T);</div><div>&nbsp;&nbsp; &nbsp;while ( T -- ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int N;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;scan_d( N );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int ma = -1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char mi[30] = "{";</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for ( int i = 0 ; i &lt; N ; ++ i ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scanf ( "%s",a[i].name);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scan_d( a[i].num );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int cnt = 0;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for ( int j = 0 ; j &lt; _Count &amp;&amp; a[i].num &gt; 1 ; ++ j ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( a[i].num%Primes[j]==0 ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while(a[i].num%Primes[j]==0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a[i].num /= Primes[j];</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cnt++; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( cnt == 0 ) cnt = 1; &nbsp;// 没加这句也能A 说明没有 1 和 超过1&lt;&lt;16的素数</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( ma &lt; cnt ) { ma = cnt; strcpy ( mi, a[i].name ); }</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if ( ma == cnt ) {&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( strcmp ( a[i].name, mi ) &lt; 0 )</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strcpy ( mi, a[i].name ); &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;puts(mi);</div><div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;return 0;</div><div>}</div></div><div><br></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;</p>
<img src ="http://www.cppblog.com/MiYu/aggbug/133819.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-16 19:43 <a href="http://www.cppblog.com/MiYu/archive/2010/11/16/133819.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 2573 HDOJ 2573 Typing ACM 2573 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/11/16/133809.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Tue, 16 Nov 2010 09:30:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/16/133809.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133809.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/16/133809.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133809.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133809.html</trackback:ping><description><![CDATA[<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">纯模拟, 没什么好说的, 直接代码&nbsp;</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_ddaf82ac-498f-4fdd-9be2-075e99a33fe8" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; font-family: 'Courier New'; ">代码</span><div id="cnblogs_code_open_ddaf82ac-498f-4fdd-9be2-075e99a33fe8"><div><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_2573&nbsp;<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;Typing<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">bool</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;isup&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;T;<br>&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;T;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;T&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">--</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;str,&nbsp;word;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;N&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">--</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;str;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;str.size()&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">char</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(&nbsp;isup&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">?</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;toupper(str[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">])&nbsp;:&nbsp;tolower&nbsp;(str[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">])&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;str&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">Caps</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;isup&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">isup;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;str;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">char</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">isup&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">?</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;toupper(str[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">])&nbsp;:&nbsp;tolower&nbsp;(str[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">])&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;word&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isup&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}<br></span></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; line-height: 21px; font-size: 16.8px; ">&nbsp;</p>
<img src ="http://www.cppblog.com/MiYu/aggbug/133809.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-16 17:30 <a href="http://www.cppblog.com/MiYu/archive/2010/11/16/133809.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 3584 HDOJ 3584 Cube  ACM 3584 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/11/14/133577.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sun, 14 Nov 2010 02:35:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/14/133577.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133577.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/14/133577.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133577.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133577.html</trackback:ping><description><![CDATA[
<span style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目描述:</p><span style="font-family: 'Times New Roman'; line-height: normal; font-size: medium; "><h1 style="color: rgb(26, 92, 200); text-align: center; ">Cube</h1><font><strong><span style="font-family: Arial; font-size: 12px; font-weight: bold; color: green; ">Time Limit: 2000/1000 MS (Java/Others)&nbsp;&nbsp;&nbsp;&nbsp;Memory Limit: 131072/65536 K (Java/Others)<br>Total Submission(s): 495&nbsp;&nbsp;&nbsp;&nbsp;Accepted Submission(s): 226<br></span></strong></font><br><br><div class="panel_title" align="left" style="height: 38px; background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; padding-top: 0px; padding-right: 14px; padding-bottom: 0px; padding-left: 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold; background-position: 0% 100%; background-repeat: no-repeat no-repeat; ">Problem Description</div><div class="panel_content" style="height: auto; background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; font-size: 14px; font-family: 'Times New Roman'; text-align: left; background-repeat: no-repeat repeat; ">Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. Initially we have A[i, j, k] = 0 (1 &lt;= i, j, k &lt;= N).&nbsp;<br>We define two operations, 1: &#8220;Not&#8221; operation that we change the A[i, j, k]=!A[i, j, k]. that means we change A[i, j, k] from 0-&gt;1,or 1-&gt;0. (x1&lt;=i&lt;=x2,y1&lt;=j&lt;=y2,z1&lt;=k&lt;=z2).<br>0: &#8220;Query&#8221; operation we want to get the value of A[i, j, k].<br></div><div class="panel_bottom" style="height: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 0%; background-repeat: no-repeat no-repeat; ">&nbsp;</div><br><div class="panel_title" align="left" style="height: 38px; background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; padding-top: 0px; padding-right: 14px; padding-bottom: 0px; padding-left: 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold; background-position: 0% 100%; background-repeat: no-repeat no-repeat; ">Input</div><div class="panel_content" style="height: auto; background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; font-size: 14px; font-family: 'Times New Roman'; text-align: left; background-repeat: no-repeat repeat; ">Multi-cases.<br>First line contains N and M, M lines follow indicating the operation below.<br>Each operation contains an X, the type of operation. 1: &#8220;Not&#8221; operation and 0: &#8220;Query&#8221; operation.<br>If X is 1, following x1, y1, z1, x2, y2, z2.<br>If X is 0, following x, y, z.<br></div><div class="panel_bottom" style="height: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 0%; background-repeat: no-repeat no-repeat; ">&nbsp;</div><br><div class="panel_title" align="left" style="height: 38px; background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; padding-top: 0px; padding-right: 14px; padding-bottom: 0px; padding-left: 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold; background-position: 0% 100%; background-repeat: no-repeat no-repeat; ">Output</div><div class="panel_content" style="height: auto; background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; font-size: 14px; font-family: 'Times New Roman'; text-align: left; background-repeat: no-repeat repeat; ">For each query output A[x, y, z] in one line. (1&lt;=n&lt;=100 sum of m &lt;=10000)</div><div class="panel_bottom" style="height: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 0%; background-repeat: no-repeat no-repeat; ">&nbsp;</div><br><div class="panel_title" align="left" style="height: 38px; background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; padding-top: 0px; padding-right: 14px; padding-bottom: 0px; padding-left: 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold; background-position: 0% 100%; background-repeat: no-repeat no-repeat; ">Sample Input</div><div class="panel_content" style="height: auto; background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; font-size: 14px; font-family: 'Times New Roman'; text-align: left; background-repeat: no-repeat repeat; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 14px; "><div style="font-family: 'Courier New', Courier, monospace; ">2 5
1 1 1 1  1 1 1
0 1 1 1
1 1 1 1  2 2 2
0 1 1 1
0 2 2 2</div></pre></div><div class="panel_bottom" style="height: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 0%; background-repeat: no-repeat no-repeat; ">&nbsp;</div><br><div class="panel_title" align="left" style="height: 38px; background-image: url(http://acm.hdu.edu.cn/images/panel-title.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; padding-top: 0px; padding-right: 14px; padding-bottom: 0px; padding-left: 14px; color: rgb(124, 169, 237); font-size: 18px; font-family: Arial; font-weight: bold; background-position: 0% 100%; background-repeat: no-repeat no-repeat; ">Sample Output</div><div class="panel_content" style="height: auto; background-image: url(http://acm.hdu.edu.cn/images/panel-content.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; font-size: 14px; font-family: 'Times New Roman'; text-align: left; background-repeat: no-repeat repeat; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 14px; "><div style="font-family: 'Courier New', Courier, monospace; ">1
0
1</div></pre></div><div class="panel_bottom" style="height: auto; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://acm.hdu.edu.cn/images/panel-bottom.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 0%; background-repeat: no-repeat no-repeat; ">&nbsp;</div></span><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目分析 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; &nbsp;更新区间, 查询一个点, 三维线段树 直接无视.........数据不是很强, 所以 直接暴力就可以过, 过完发现自己的时间 在700MS 左右, 看了下rank,</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">小A 榜首..... 时间竟然才62MS<img src="http://www.cnblogs.com/Emoticons/baimantou/134950312.gif">....果然还是要用三维树状数组来加速啊 . 不过一直没理解 用 树状数组 解决这题的思路, 今早上终于明白了<img src="http://www.cnblogs.com/Emoticons/baimantou/22571567.gif">.</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">画个图先 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img src="http://www.cnblogs.com/images/cnblogs_com/miyu/HDU_3485.JPG" width="422" height="193" alt="">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">好了 , 看代码:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">树状数组代码 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;<span style="font-family: 'Courier New'; line-height: normal; font-size: 12px; color: rgb(0, 128, 0); white-space: pre; ">/*</span></p><span style="font-family: 'Times New Roman'; line-height: normal; font-size: 12px; "><div style="padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; "><pre style="font-family: 'Courier New'; text-align: left; "><font color="green">Mail to   : miyubai@gamil.com
My Blog   : www.baiyun.me
Link      : http://www.cnblogs.com/MiYu  || http://www.cppblog.com/MiYu
Author By : MiYu
Test      : 1
Complier  : g++ mingw32-3.4.2
Program   : HDU_3584
Doc Name  : Cube
*/</font><font color="green">
//#pragma warning( disable:4789 )
</font><font color="blue">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;algorithm&gt;
#include &lt;string&gt;
#include &lt;set&gt;
#include &lt;map&gt;
#include &lt;utility&gt;
#include &lt;queue&gt;
#include &lt;stack&gt;
#include &lt;list&gt;
#include &lt;vector&gt;
#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;cstring&gt;
#include &lt;cmath&gt;
#include &lt;ctime&gt;
</font><strong><font color="#0000FF">using namespace</font></strong> std<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
inline</font></strong><strong><font color="blue"> bool</font></strong> scan_d<strong><font color="#FF00FF">(</font></strong><strong><font color="blue">int</font></strong><strong><font color="#FF00FF"> &amp;</font></strong>num<strong><font color="#FF00FF">)</font></strong><font color="green">  //整数输入
</font><strong><font color="#FF00FF">{</font></strong><strong><font color="blue">
        char</font></strong> in<strong><font color="#FF00FF">;</font></strong><strong><font color="blue">bool</font></strong> IsN<strong><font color="#FF00FF">=</font></strong><font color="#CC3300">false</font><strong><font color="#FF00FF">;</font></strong>
        in<strong><font color="#FF00FF">=</font></strong>getchar<strong><font color="#FF00FF">();</font></strong><strong><font color="#0000FF">
        if</font></strong><strong><font color="#FF00FF">(</font></strong>in<strong><font color="#FF00FF">==</font></strong>EOF<strong><font color="#FF00FF">)</font></strong><strong><font color="#0000FF"> return</font></strong><font color="#CC3300"> false</font><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
        while</font></strong><strong><font color="#FF00FF">(</font></strong>in<strong><font color="#FF00FF">!=</font></strong><font color="green">'-'</font><strong><font color="#FF00FF">&amp;&amp;(</font></strong>in<strong><font color="#FF00FF">&lt;</font></strong><font color="green">'0'</font><strong><font color="#FF00FF">||</font></strong>in<strong><font color="#FF00FF">&gt;</font></strong><font color="green">'9'</font><strong><font color="#FF00FF">))</font></strong> in<strong><font color="#FF00FF">=</font></strong>getchar<strong><font color="#FF00FF">();</font></strong><strong><font color="#0000FF">
        if</font></strong><strong><font color="#FF00FF">(</font></strong>in<strong><font color="#FF00FF">==</font></strong><font color="green">'-'</font><strong><font color="#FF00FF">){</font></strong> IsN<strong><font color="#FF00FF">=</font></strong><font color="#CC3300">true</font><strong><font color="#FF00FF">;</font></strong>num<strong><font color="#FF00FF">=</font></strong><font color="#CC3300">0</font><strong><font color="#FF00FF">;}</font></strong><strong><font color="#0000FF">
        else</font></strong> num<strong><font color="#FF00FF">=</font></strong>in<strong><font color="#FF00FF">-</font></strong><font color="green">'0'</font><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
        while</font></strong><strong><font color="#FF00FF">(</font></strong>in<strong><font color="#FF00FF">=</font></strong>getchar<strong><font color="#FF00FF">(),</font></strong>in<strong><font color="#FF00FF">&gt;=</font></strong><font color="green">'0'</font><strong><font color="#FF00FF">&amp;&amp;</font></strong>in<strong><font color="#FF00FF">&lt;=</font></strong><font color="green">'9'</font><strong><font color="#FF00FF">){</font></strong>
                num<strong><font color="#FF00FF">*=</font></strong><font color="#CC3300">10</font><strong><font color="#FF00FF">,</font></strong>num<strong><font color="#FF00FF">+=</font></strong>in<strong><font color="#FF00FF">-</font></strong><font color="green">'0'</font><strong><font color="#FF00FF">;
        }</font></strong><strong><font color="#0000FF">
        if</font></strong><strong><font color="#FF00FF">(</font></strong>IsN<strong><font color="#FF00FF">)</font></strong> num<strong><font color="#FF00FF">=-</font></strong>num<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
        return</font></strong><font color="#CC3300"> true</font><strong><font color="#FF00FF">;
}</font></strong><strong><font color="#0000FF">
const</font></strong><strong><font color="blue"> int</font></strong> MAXN<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 105</font><strong><font color="#FF00FF">;</font></strong><strong><font color="blue">
int</font></strong> mat<strong><font color="#FF00FF">[</font></strong>MAXN<strong><font color="#FF00FF">][</font></strong>MAXN<strong><font color="#FF00FF">][</font></strong>MAXN<strong><font color="#FF00FF">];</font></strong><strong><font color="blue">
int</font></strong> low<strong><font color="#FF00FF">[</font></strong>MAXN<strong><font color="#FF00FF">];</font></strong><strong><font color="blue">
int</font></strong> i<strong><font color="#FF00FF">,</font></strong> j<strong><font color="#FF00FF">,</font></strong> k<strong><font color="#FF00FF">;</font></strong><strong><font color="blue">
void</font></strong> setLow<strong><font color="#FF00FF"> () {</font></strong><strong><font color="#0000FF">
     for</font></strong><strong><font color="#FF00FF"> (</font></strong> i<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> &lt;=</font></strong> MAXN<strong><font color="#FF00FF">; ++</font></strong> i<strong><font color="#FF00FF"> )</font></strong> low<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">] =</font></strong> i<strong><font color="#FF00FF"> &amp; (-</font></strong> i<strong><font color="#FF00FF">);
}</font></strong><strong><font color="blue">
void</font></strong> modify<strong><font color="#FF00FF"> (</font></strong><strong><font color="blue"> int</font></strong> x<strong><font color="#FF00FF">,</font></strong><strong><font color="blue"> int</font></strong> y<strong><font color="#FF00FF">,</font></strong><strong><font color="blue"> int</font></strong> z<strong><font color="#FF00FF"> ) {</font></strong><strong><font color="#0000FF">
     for</font></strong><strong><font color="#FF00FF"> (</font></strong> i<strong><font color="#FF00FF"> =</font></strong> x<strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> &lt;=</font></strong> MAXN<strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> +=</font></strong> low<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">] ) {</font></strong><strong><font color="#0000FF">
         for</font></strong><strong><font color="#FF00FF"> (</font></strong> j<strong><font color="#FF00FF"> =</font></strong> y<strong><font color="#FF00FF">;</font></strong> j<strong><font color="#FF00FF"> &lt;=</font></strong> MAXN<strong><font color="#FF00FF">;</font></strong> j<strong><font color="#FF00FF"> +=</font></strong> low<strong><font color="#FF00FF">[</font></strong>j<strong><font color="#FF00FF">] ) {</font></strong><strong><font color="#0000FF">
             for</font></strong><strong><font color="#FF00FF"> (</font></strong> k<strong><font color="#FF00FF"> =</font></strong> z<strong><font color="#FF00FF">;</font></strong> k<strong><font color="#FF00FF"> &lt;=</font></strong> MAXN<strong><font color="#FF00FF">;</font></strong> k<strong><font color="#FF00FF"> +=</font></strong> low<strong><font color="#FF00FF">[</font></strong>k<strong><font color="#FF00FF">] )</font></strong>
                 mat<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">][</font></strong>j<strong><font color="#FF00FF">][</font></strong>k<strong><font color="#FF00FF">] ^=</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">;   
         }    
     }    
}</font></strong><strong><font color="blue">
int</font></strong> query<strong><font color="#FF00FF"> (</font></strong><strong><font color="blue"> int</font></strong> x<strong><font color="#FF00FF">,</font></strong><strong><font color="blue"> int</font></strong> y<strong><font color="#FF00FF">,</font></strong><strong><font color="blue"> int</font></strong> z<strong><font color="#FF00FF"> ) {</font></strong><strong><font color="blue">
     int</font></strong> sum<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
     for</font></strong><strong><font color="#FF00FF"> (</font></strong> i<strong><font color="#FF00FF"> =</font></strong> x<strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> &gt;</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> ^=</font></strong> low<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">] ) {</font></strong><strong><font color="#0000FF">
         for</font></strong><strong><font color="#FF00FF"> (</font></strong> j<strong><font color="#FF00FF"> =</font></strong> y<strong><font color="#FF00FF">;</font></strong> j<strong><font color="#FF00FF"> &gt;</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong> j<strong><font color="#FF00FF"> ^=</font></strong> low<strong><font color="#FF00FF">[</font></strong>j<strong><font color="#FF00FF">] ) {</font></strong><strong><font color="#0000FF">
             for</font></strong><strong><font color="#FF00FF"> (</font></strong> k<strong><font color="#FF00FF"> =</font></strong> z<strong><font color="#FF00FF">;</font></strong> k<strong><font color="#FF00FF"> &gt;</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong> k<strong><font color="#FF00FF"> ^=</font></strong> low<strong><font color="#FF00FF">[</font></strong>k<strong><font color="#FF00FF">] )</font></strong>
                 sum<strong><font color="#FF00FF"> +=</font></strong> mat<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">][</font></strong>j<strong><font color="#FF00FF">][</font></strong>k<strong><font color="#FF00FF">];    
         }    
     }</font></strong><strong><font color="#0000FF">    
     return</font></strong> sum<strong><font color="#FF00FF"> &amp;</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">;
}</font></strong><strong><font color="blue">
int</font></strong><strong><font color="#0000FF"> main</font></strong><strong><font color="#FF00FF"> ()
{</font></strong>
    setLow<strong><font color="#FF00FF"> ();</font></strong><strong><font color="blue">
    int</font></strong> N<strong><font color="#FF00FF">,</font></strong> M<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
    while</font></strong><strong><font color="#FF00FF"> (</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> N<strong><font color="#FF00FF"> ) &amp;&amp;</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> M<strong><font color="#FF00FF"> ) ) {</font></strong>
          memset<strong><font color="#FF00FF"> (</font></strong> mat<strong><font color="#FF00FF">,</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">,</font></strong><strong><font color="#0000FF"> sizeof</font></strong><strong><font color="#FF00FF"> (</font></strong> mat<strong><font color="#FF00FF"> ) );</font></strong><strong><font color="#0000FF">
          while</font></strong><strong><font color="#FF00FF"> (</font></strong> M<strong><font color="#FF00FF"> -- ) {</font></strong><strong><font color="blue">
                int</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF">,</font></strong>x2<strong><font color="#FF00FF">,</font></strong>y2<strong><font color="#FF00FF">,</font></strong>z2<strong><font color="#FF00FF">;</font></strong><strong><font color="blue">
                int</font></strong> s<strong><font color="#FF00FF">;</font></strong>  scan_d<strong><font color="#FF00FF"> (</font></strong> s<strong><font color="#FF00FF"> );</font></strong><strong><font color="#0000FF"> 
                switch</font></strong><strong><font color="#FF00FF"> (</font></strong> s<strong><font color="#FF00FF"> ) {</font></strong><strong><font color="#0000FF">
                       case</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">:</font></strong>
                            scan_d<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> y1<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> z1<strong><font color="#FF00FF"> );</font></strong> 
                            scan_d<strong><font color="#FF00FF"> (</font></strong> x2<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> y2<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> z2<strong><font color="#FF00FF"> );</font></strong>
                            modify<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF"> );</font></strong>    modify<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF"> );</font></strong>
                            modify<strong><font color="#FF00FF"> (</font></strong> x2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF"> );</font></strong>    modify<strong><font color="#FF00FF"> (</font></strong> x2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF"> );</font></strong>
                            modify<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF"> );</font></strong>    modify<strong><font color="#FF00FF"> (</font></strong> x2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>y2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF"> );</font></strong>
                            modify<strong><font color="#FF00FF"> (</font></strong> x2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>y2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>z2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF"> );</font></strong>    modify<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF">,</font></strong>z2<strong><font color="#FF00FF">+</font></strong><font color="#CC3300">1</font><strong><font color="#FF00FF"> );</font></strong><strong><font color="#0000FF"> 
                            break</font></strong><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
                       case</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">:</font></strong>
                            scan_d<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> y1<strong><font color="#FF00FF"> );</font></strong> scan_d<strong><font color="#FF00FF"> (</font></strong> z1<strong><font color="#FF00FF"> );</font></strong>
                            printf<strong><font color="#FF00FF"> (</font></strong><font color="green"> "%d\n"</font><strong><font color="#FF00FF">,</font></strong> query<strong><font color="#FF00FF"> (</font></strong> x1<strong><font color="#FF00FF">,</font></strong>y1<strong><font color="#FF00FF">,</font></strong>z1<strong><font color="#FF00FF"> ) );      
                }
          }           
    }</font></strong><strong><font color="#0000FF">
    return</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;
}</font></strong>
</pre><div><strong><font color="#FF00FF"><br></font></strong></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">暴力代码 :<br></p><div style="padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; "><pre style="font-family: 'Courier New'; text-align: left; "><font color="green">/*
Mail to   : miyubai@gamil.com
My Blog   : www.baiyun.me
Link      : http://www.cnblogs.com/MiYu  || http://www.cppblog.com/MiYu
Author By : MiYu
Test      : 1
Complier  : g++ mingw32-3.4.2
Program   :
Doc Name  :
*/</font><font color="green">
//#pragma warning( disable:4789 )
</font><font color="blue">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;algorithm&gt;
#include &lt;string&gt;
#include &lt;set&gt;
#include &lt;map&gt;
#include &lt;utility&gt;
#include &lt;queue&gt;
#include &lt;stack&gt;
#include &lt;list&gt;
#include &lt;vector&gt;
#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;cstring&gt;
#include &lt;cmath&gt;
#include &lt;ctime&gt;
</font><strong><font color="#0000FF">using namespace</font></strong> std<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
struct</font></strong> node<strong><font color="#FF00FF"> {</font></strong><strong><font color="blue">  
    int</font></strong> x1<strong><font color="#FF00FF">,</font></strong> x2<strong><font color="#FF00FF">,</font></strong> y1<strong><font color="#FF00FF">,</font></strong> y2<strong><font color="#FF00FF">,</font></strong> z1<strong><font color="#FF00FF">,</font></strong> z2<strong><font color="#FF00FF">; 
}</font></strong>cube<strong><font color="#FF00FF">[</font></strong><font color="#CC3300">10010</font><strong><font color="#FF00FF">];</font></strong><strong><font color="blue">   
  
int</font></strong><strong><font color="#0000FF"> main</font></strong><strong><font color="#FF00FF">()  
{</font></strong><strong><font color="blue">  
    int</font></strong> N<strong><font color="#FF00FF">,</font></strong> M<strong><font color="#FF00FF">;</font></strong><strong><font color="blue">  
    int</font></strong> x<strong><font color="#FF00FF">,</font></strong> y<strong><font color="#FF00FF">,</font></strong> z<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
    while</font></strong><strong><font color="#FF00FF"> (</font></strong> scanf<strong><font color="#FF00FF"> (</font></strong><font color="green"> "%d%d"</font><strong><font color="#FF00FF">,&amp;</font></strong>N<strong><font color="#FF00FF">,&amp;</font></strong>M<strong><font color="#FF00FF"> ) !=</font></strong> EOF<strong><font color="#FF00FF"> )  {</font></strong><strong><font color="blue">  
        int</font></strong> cnt<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">  
        while</font></strong><strong><font color="#FF00FF"> (</font></strong> M<strong><font color="#FF00FF"> -- )  
        {</font></strong><strong><font color="blue">  
            int</font></strong> ask<strong><font color="#FF00FF">;</font></strong>  
            scanf<strong><font color="#FF00FF"> (</font></strong><font color="green"> "%d"</font><strong><font color="#FF00FF">, &amp;</font></strong>ask<strong><font color="#FF00FF"> );</font></strong><strong><font color="#0000FF">  
            switch</font></strong><strong><font color="#FF00FF"> (</font></strong> ask<strong><font color="#FF00FF"> ) {</font></strong><strong><font color="#0000FF">
                case</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">:</font></strong>   
                    scanf<strong><font color="#FF00FF"> (</font></strong><font color="green"> "%d%d%d%d%d%d"</font><strong><font color="#FF00FF">, &amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>x1<strong><font color="#FF00FF">,&amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>y1<strong><font color="#FF00FF">,
                                            &amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>z1<strong><font color="#FF00FF">,&amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>x2<strong><font color="#FF00FF">,
                                            &amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>y2<strong><font color="#FF00FF">,&amp;</font></strong>cube<strong><font color="#FF00FF">[</font></strong>cnt<strong><font color="#FF00FF">].</font></strong>z2<strong><font color="#FF00FF"> );  
                    ++</font></strong> cnt<strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">  
                    break</font></strong><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">
                case</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">:</font></strong>
                    scanf<strong><font color="#FF00FF"> (</font></strong><font color="green"> "%d%d%d"</font><strong><font color="#FF00FF">, &amp;</font></strong>x<strong><font color="#FF00FF">, &amp;</font></strong>y<strong><font color="#FF00FF">, &amp;</font></strong>z<strong><font color="#FF00FF">);</font></strong><strong><font color="blue">  
                    int</font></strong> count<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong><strong><font color="#0000FF">  
                    for</font></strong><strong><font color="#FF00FF"> (</font></strong><strong><font color="blue"> int</font></strong> i<strong><font color="#FF00FF"> =</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;</font></strong> i<strong><font color="#FF00FF"> !=</font></strong> cnt<strong><font color="#FF00FF">; ++</font></strong> i<strong><font color="#FF00FF"> )</font></strong><strong><font color="#0000FF">  
                        if</font></strong><strong><font color="#FF00FF"> (</font></strong> cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>x1<strong><font color="#FF00FF"> &lt;=</font></strong> x<strong><font color="#FF00FF"> &amp;&amp;</font></strong> x<strong><font color="#FF00FF"> &lt;=</font></strong> cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>x2<strong><font color="#FF00FF"> &amp;&amp;</font></strong> 
                             cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>y1<strong><font color="#FF00FF"> &lt;=</font></strong> y<strong><font color="#FF00FF"> &amp;&amp;</font></strong> y<strong><font color="#FF00FF"> &lt;=</font></strong> cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>y2<strong><font color="#FF00FF"> &amp;&amp;</font></strong> 
                             cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>z1<strong><font color="#FF00FF"> &lt;=</font></strong> z<strong><font color="#FF00FF"> &amp;&amp;</font></strong> z<strong><font color="#FF00FF"> &lt;=</font></strong> cube<strong><font color="#FF00FF">[</font></strong>i<strong><font color="#FF00FF">].</font></strong>z2<strong><font color="#FF00FF"> )</font></strong>  
                                    count<strong><font color="#FF00FF"> ^=</font></strong><font color="#CC3300"> 1</font><strong><font color="#FF00FF">;;</font></strong>  
                    puts<strong><font color="#FF00FF"> (</font></strong> count<strong><font color="#FF00FF"> ?</font></strong><font color="green"> "1"</font><strong><font color="#FF00FF"> :</font></strong><font color="green"> "0"</font><strong><font color="#FF00FF"> ); 
            }  
        }  
    }</font></strong><strong><font color="#0000FF">  
    return</font></strong><font color="#CC3300"> 0</font><strong><font color="#FF00FF">;  
}</font></strong>  
</pre></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p></div></span></span><img src ="http://www.cppblog.com/MiYu/aggbug/133577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-14 10:35 <a href="http://www.cppblog.com/MiYu/archive/2010/11/14/133577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>(转)伸展树 ( Splay tree )</title><link>http://www.cppblog.com/MiYu/archive/2010/11/12/133405.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Fri, 12 Nov 2010 03:13:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/12/133405.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133405.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/12/133405.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133405.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133405.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MiYu原创, 转帖请注明 : 转载自&nbsp;______________白白の屋&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;伸展树(Splay Tree)是AVL树不错的替代，它有以下几个特点：(1)它是二叉查找树的改进，所以具有二叉查找树的有序性。(2)对伸展树的操作的平摊复杂度是O(log2n)。(3)伸展树的空间要求、编程难度非常低。提到伸展树，就不得不提到AVL树和R...&nbsp;&nbsp;<a href='http://www.cppblog.com/MiYu/archive/2010/11/12/133405.html'>阅读全文</a><img src ="http://www.cppblog.com/MiYu/aggbug/133405.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-12 11:13 <a href="http://www.cppblog.com/MiYu/archive/2010/11/12/133405.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Splay Tree 介绍</title><link>http://www.cppblog.com/MiYu/archive/2010/11/12/133404.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Fri, 12 Nov 2010 03:13:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/12/133404.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133404.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/12/133404.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133404.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133404.html</trackback:ping><description><![CDATA[<span  style="font-size: 12px; "><div style="padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; "><pre style="font-family: 'Courier New'; text-align: left; "><span  style="font-family: verdana, 'courier new'; white-space: normal; font-size: 14px; line-height: 21px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</span></pre><pre style="font-family: 'Courier New'; text-align: left; "><span  style="font-family: verdana, 'courier new'; white-space: normal; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p></span></pre><pre style="font-family: 'Courier New'; text-align: left; ">伸展树（Splay Tree）是一种二叉排序树，它能在O<strong><font color="#FF00FF">(</font></strong>log n<strong><font color="#FF00FF">)</font></strong>内完成插入、查找和删除操作。它由Daniel Sleator和Robert Tarjan创造。它的优势在于不需要记录用于平衡树的冗余信息。在伸展树上的一般操作都基于伸展操作。
查找树的相关知识
　　各种查找树存在不足。比如：对于一个有n个节点的平衡树，虽然最坏情况下每次查找的时间复杂度不会超过O<strong><font color="#FF00FF">(</font></strong>logn<strong><font color="#FF00FF">)</font></strong>，但是如果访问模式不均匀，平衡树的效率就会受到影响。此外，它们还需要额外的空间来存储平衡信息。 
　　这些查找树的设计目标都是减少最坏情况下单次操作时间，但是查找树的典型应用经常需要执行一系列的查找操作，此时更关心的性能指标是所有这些操作总共需要多少时间。对于此类应用，更好的目标就是降低操作的摊平时间，此处的摊平时间是指在一系列最坏情况的操作序列中单次操作的平均时间。获得摊平效率的一种方法 就是使用&#8220;自调整&#8221;的数据结构。 
　　和平衡的或是其它对结构有明确限制的数据结构比起来，自调整数据结构有以下几个优点：<font color="#CC3300"> 
　　1</font>、从摊平角度而言，它们忽略常量因子，因此绝对不会比有明确限制的数据结构差。而且由于它们可以根据使用情况进行调整，于是在使用模式不均匀的情况下更加有效。<font color="#CC3300"> 
　　2</font>、由于无需存储平衡或者其它的限制信息，它们所需的空间更小。<font color="#CC3300"> 
　　3</font>、它们的查找和更新算法概念简单，易于实现。 
　　当然，自调整结构也有潜在的缺点：<font color="#CC3300"> 
　　1</font>、它们需要更多的局部调整，尤其是在查找期间。（那些有明确限制的数据结构仅需在更新期间进行调整，查找期间则不用）<font color="#CC3300"> 
　　2</font>、一系列查找操作中的某一个可能会耗时较长，这在实时应用程序中可能是个不足之处。
伸展树存在的意义
　　假设想要对一个二叉查找树执行一系列的查找操作。为了使整个查找时间更小，被查频率高的那些条目就应当经常处于靠近树根的位置。于是想到设计一个简单方法， 在每次查找之后对树进行重构，把被查找的条目搬移到离树根近一些的地方。splay tree应运而生。splay tree是一种自调整形式的二叉查找树，它会沿着从某个节点到树根之间的路径，通过一系列的旋转把这个节点搬移到树根去。
已知重构方法与伸展树的重构方法
　　先前，已经存在两种重构方法：<font color="#CC3300"> 
　　1</font>、单旋：在查找完位于节点x中的条目i之后，旋转链接x和其父节点的边。（除非x就是树根）<font color="#CC3300"> 
　　2</font>、搬移至树根：在查找完位于节点x中的条目i之后，旋转链接x和其父节点的边，然后重复这个操作直至x成为树根。 
　　splay tree的重构方法和搬移至树根的方法相似，它也会沿着查找路径做自底向上的旋转，将被查找条目移至树根。但不同的是，它的旋转是成对进行的，顺序取决于查找路径的结构。为了在节点x处对树进行splay操作，我们需要重复下面的步骤，直至x成为树根为止：<font color="#CC3300"> 
　　1</font>、第一种情况：如果x的父节点p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>是树根，则旋转连接x和p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>的边。（这种情况是最后一步）<font color="#CC3300"> 
　　2</font>、第二种情况：如果p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>不是树根，而且x和p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>本身都是左孩子或者都是右孩子，则先旋转连接p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>和x的祖父节点g<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>的边，然后再旋转连接x和p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>的边。<font color="#CC3300"> 
　　3</font>、第三种情况：如果p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>不是树根，而且x是左孩子，p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>是右孩子，或者相反，则先旋转连接x和p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>的边，再旋转连接x和新的p<strong><font color="#FF00FF">(</font></strong>x<strong><font color="#FF00FF">)</font></strong>的边。 
　　在节点x处进行splay操作的时间是和查找x所需的时间成比例的。splay操作不单是把x搬移到了树根，而且还把查找路径上的每个节点的深度都大致减掉了一半。
伸展树（Splay Tree）支持的操作
　　具体操作包括：<font color="#CC3300"> 
　　1</font>、access<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">):</font></strong>如果i在树t中，则返回指向它的指针，否则返回空指针。为了实现access<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，可以从树t的根部向下查找i。如果 查找操作遇到了一个含有i的节点x，就在x处进行splay操作，并返回指向x的指针，访问结束。如果遇到了空指针，表示i不在树中，此时就在最后一个非 空节点处进行splay操作，然后返回空指针。如果树是空的，将忽略掉splay操作。<font color="#CC3300"> 
　　2</font>、insert<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">):</font></strong>将条目i插入树t中（假设其尚不存在）。为了实现insert<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，首先执行split<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，然后把t换成一个由新的包含有i的根节点组成的树，这个根节点的左右子树分别是split返回的树t1和t2。<font color="#CC3300"> 
　　3</font>、<strong><font color="#0000FF">delete</font></strong><strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">):</font></strong>从树t中删除条目i（假设其已经存在）。为了实现<strong><font color="#0000FF">delete</font></strong><strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，首先执行access<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，然后把t换成其左子树和右子树join之后的新树。<font color="#CC3300"> 
　　4</font>、join<strong><font color="#FF00FF">(</font></strong>t1<strong><font color="#FF00FF">,</font></strong>t2<strong><font color="#FF00FF">):</font></strong>将树t1和t2合并成一棵树，其中包含之前两棵树的所有条目，并返回合并之后的树。这个操作假设t1中的所有条目都小于t2 中的条目，操作完成之后会销毁t1和t2。为了实现join<strong><font color="#FF00FF">(</font></strong>t1<strong><font color="#FF00FF">,</font></strong>t2<strong><font color="#FF00FF">)</font></strong>，首先访问t1中最大的条目i。访问结束之后，t1的根节点中包含的就是i，它 的右孩子显然为空。于是把t2作为这个根节点的右子树并返回完成之后的新树即可实现join操作。<font color="#CC3300"> 
　　5</font>、split<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">):</font></strong>构建并返回两棵树t1和t2，其中t1包含t中所有小于等于i的条目，t2包含t中所有大于i的条目。操作完成之后销毁t。为 了实现split<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，首先执行access<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong>t<strong><font color="#FF00FF">)</font></strong>，然后根据新根节点中的值是大于还是小于等于i来切断这个根节点的左链接或右链接，并返回形 成的两棵树。 
　　另外insert和<strong><font color="#0000FF">delete</font></strong>方法有更好的实现，时间复杂度更小：<font color="#CC3300"> 
　　1</font>、insert<strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong> t<strong><font color="#FF00FF">):</font></strong>查找i，把遇到的空指针替换成一个含有i的新节点，然后再在新节点处对树进行splay操作。<font color="#CC3300"> 
　　2</font>、<strong><font color="#0000FF">delete</font></strong><strong><font color="#FF00FF">(</font></strong>i<strong><font color="#FF00FF">,</font></strong> t<strong><font color="#FF00FF">):</font></strong>查找含有i的节点，设此节点为x，其父节点为y。把x的左右子树合并之后替换掉x，然后再从y处进行splay操作。
伸展树的优势
　　由于Splay Tree仅仅是不断调整，并没有引入额外的标记，因而树结构与标准BST没有任何不同，从空间角度来看，它比Treap、Red<strong><font color="#FF00FF">-</font></strong>Black Tree、AVL要高效得多。因为结构不变，因此只要是通过左旋和右旋进行的操作对Splay Tree性质都没有丝毫影响，因而它也提供了BST中最丰富的功能，包括快速的拆分和合并（这里指的是将原树拆分成两棵子树，其中一棵子树所有节点都比另一子树小，以及它的逆过程），并且实现极为便捷。这一点是其它结构较难实现的。其时间效率也相当稳定，和Treap基本相当</pre></div></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/133404.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-12 11:13 <a href="http://www.cppblog.com/MiYu/archive/2010/11/12/133404.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>成都区域赛酱油总结</title><link>http://www.cppblog.com/MiYu/archive/2010/11/09/133085.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Tue, 09 Nov 2010 04:19:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/09/133085.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/133085.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/09/133085.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/133085.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/133085.html</trackback:ping><description><![CDATA[<span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp;第一次参加这么大型的赛事, 去的时候有点小小的激动, &nbsp;貌似也是我们学校的第一次......囧<img src="http://www.cnblogs.com/Emoticons/baimantou/202015694.gif">...第一次坐火车, 第一次去成都, 貌似一路经过的地方都是没去过的<img src="http://www.cnblogs.com/Emoticons/baimantou/114325779.gif">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">上了火车后开始郁闷了, 20多个小时的车程, =. &nbsp;=<img src="http://www.cnblogs.com/Emoticons/baimantou/134950908.gif">&nbsp;&nbsp;表示这也是从来没有过的.... &nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp;到了成都后发现, &nbsp;果然西部最大城市不是吹的, &nbsp;火车站都大了好多. &nbsp;接下来我们( 涛 和小晨 ) 四川辣妹子没看到 , 到直接体会到了 &nbsp;辣大叔 彪 公交车的 感觉, 那 激情....</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">没的说.<img src="http://www.cnblogs.com/Emoticons/baimantou/134950312.gif">&nbsp;&nbsp; &nbsp; &nbsp; 貌似我们这次 成都 行 RP 一直很差, &nbsp;终于抵达旅馆 竟然不到 8点不给进房间......无赖只能去街上游荡<img src="http://www.cnblogs.com/Emoticons/baimantou/21522581.gif">.</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;接下来的一天就是 报到, 闲逛 and so on ... &nbsp;( &nbsp;傍晚被华丽的抛弃了.....泪奔...&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/201937519.gif">&nbsp; )</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">6号星期六的时候, 很多人基本都来了 , &nbsp;见到了小晨口中 传说中的 球球, 天涯 ======= &nbsp; &nbsp;下午热身赛的时候 终于 &nbsp;成功 膜拜 小冬冬 ( 冬神 ) &nbsp;0rz..... &nbsp; &nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">下午的时候奇迹般的竟然学会了怎么玩 三国杀, &nbsp;和天涯 剑剑(?是这个字不?) 南南( =. = &nbsp;表示不知道哪个字,乱打了 &nbsp;) &nbsp;球球 以及 涛和小晨 玩的时候 &nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">奇迹般的 RP 大爆发, &nbsp;赢了几次...... &nbsp;&nbsp;&nbsp;难道是这样把第二天的人品耗光了??? &nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/103828514.gif">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">7号 星期天 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; &nbsp;在赛场有幸 拍到了 傻崽 的肩膀.... 囧<img src="http://www.cnblogs.com/Emoticons/baimantou/114325779.gif">. &nbsp;( 其实我本来是想拍脑袋来着, &nbsp; 突然觉得不太好, 就拍肩膀了) &nbsp; ... 认错人了.............................</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">因为其着装 和 体型 与 小冬冬实在过于相似&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332413.gif">&nbsp;&nbsp;. &nbsp; 独自说了 几句没营养的话说后, &nbsp;hh 神一般的抛给我一句话 : &nbsp;你是不是认错人了? &nbsp; ( 因为开始我是站在他后面</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">加上 我站着 他坐着, &nbsp;一时没看清长相 ) &nbsp;仔细一看...... &nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/202015412.gif">&nbsp;&nbsp; 扔下句 "不好意思, 认错人了", 尴尬逃离.................. &nbsp;真囧</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">比赛一开始我们就 开始杯具了, &nbsp; 最基本的一道题我们竟然 交错一次....<img src="http://www.cnblogs.com/Emoticons/baimantou/134950908.gif">&nbsp;&nbsp; &nbsp;然后在 f 题 和 J 题上卡题, 直到 比赛结束...... &nbsp; 华丽的被酱油...................</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">ZUCC队成功升级到铜器时代, &nbsp;我们杯具的升级失败, 仍然混迹在铁器时代&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/134950908.gif">&nbsp;..... &nbsp;失败原因, &nbsp;一个是文化程度太低, 很多题看懂不会做; &nbsp;二个是 卡题 情况很严重;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">三个是我太弱势, &nbsp;题目看完后没有主动提出做题, 而是选择为 涛和小晨 讲题, 把做题的负担扔给它们, 使得他们心情在卡题心情极度不好的情况下 更加 不好..... &nbsp;究其原因</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">是自己一直认为 自己会的, 他们都会, 所以没必要丢丑 用自己拿 恶心的 APM ; &nbsp;四是在明知道队友卡题的情况下没有及时的提醒, 而错过了其他的能做的题目. &nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; 继续提高自己的文化程度, &nbsp;我们竟然连一个最佳匹配的模板题都没做出来...........&nbsp;</p></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/133085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-09 12:19 <a href="http://www.cppblog.com/MiYu/archive/2010/11/09/133085.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>10省赛后 好累........</title><link>http://www.cppblog.com/MiYu/archive/2010/11/01/132034.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Mon, 01 Nov 2010 12:52:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/11/01/132034.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/132034.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/11/01/132034.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/132034.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/132034.html</trackback:ping><description><![CDATA[<span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;前天去 长沙理工大学参加了省赛, &nbsp;感觉就是一个字 ---&gt; 累........... &nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/134950908.gif">&nbsp;&nbsp; &nbsp;住不好 &nbsp; 吃不好 , &nbsp;大清早 5点就 一群人吵个不停 &nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/103828514.gif"></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;那车坐得太晕了 , 到现在头还晕呼呼的 ......&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/21522581.gif">, &nbsp; 比赛的时候 理解错了 一开始就往英文题里找水题, 结果 看rank &nbsp;竟然直接就是ABC三题.......</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">这邪恶的............<img src="http://www.cnblogs.com/Emoticons/baimantou/201937664.gif">&nbsp;&nbsp; &nbsp; &nbsp;涛神速度水掉3题, 接下来就是 杯具时间了 , &nbsp;E 题的 2分答案 时 &nbsp;错了个 else, &nbsp;D 题 羊神 一开始思路就错了 , 我的F 题......</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">那火大的DFS , 剪枝一直没剪成功, &nbsp;这题提交次数最多的 恐怕就是我了 =. &nbsp;= &nbsp; &nbsp;一直在 WA 和 TLE 之间徘徊 表示很郁闷, 最后半小时一看rank , 发现</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">就算做出来 也是个 银一 &nbsp;= . = &nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/134950908.gif">&nbsp;&nbsp; 头晕死了 &nbsp; 直接放弃........... &nbsp; &nbsp; &nbsp; &nbsp;总体来说....... 这次我们好杯具</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">就像这图一样 &nbsp;&nbsp;<img src="http://www.cnblogs.com/images/cnblogs_com/miyu/%E6%9C%AA%E5%91%BD%E5%90%8D.jpg" width="269" height="118" alt="">&nbsp;</p></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/132034.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-11-01 20:52 <a href="http://www.cppblog.com/MiYu/archive/2010/11/01/132034.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>树状数组 （Binary Indexed Trees ）论文解析</title><link>http://www.cppblog.com/MiYu/archive/2010/10/29/131711.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Fri, 29 Oct 2010 01:47:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/29/131711.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131711.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/29/131711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131711.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131711.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: By&nbsp;boba5551TopCoder MemberIntroductionWe often need some sort of data structure to make our algorithms faster. In this article we willdiscuss the&nbsp;Binary Indexed Trees&nbsp;structure. Accordi...&nbsp;&nbsp;<a href='http://www.cppblog.com/MiYu/archive/2010/10/29/131711.html'>阅读全文</a><img src ="http://www.cppblog.com/MiYu/aggbug/131711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-29 09:47 <a href="http://www.cppblog.com/MiYu/archive/2010/10/29/131711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 3082 HDOJ 3082 Simplify The Circuit ACM 3082 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/10/28/131671.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Thu, 28 Oct 2010 14:23:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/28/131671.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131671.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/28/131671.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131671.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131671.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8"><span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; line-height: normal; font-size: 13px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目地址 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "><a href="http://acm.hdu.edu.cn/showproblem.php?pid=3082">http://acm.hdu.edu.cn/showproblem.php?pid=3082</a></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目分析:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; 没什么特殊的方法, 简单模拟就可以了 &nbsp;:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;代码 :</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_77214648-0457-4248-8994-41a3150567f1" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; font-family: 'Courier New'; ">代码</span><div id="cnblogs_code_open_77214648-0457-4248-8994-41a3150567f1"><div><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_3082<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;Simplify&nbsp;The&nbsp;Circuit<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">char</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;str[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">110</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">char</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">tok;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;T;<br>&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">T&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;T&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">--</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">double</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;res&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">N&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%s</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;str&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tok&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;strtok&nbsp;(&nbsp;str,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;t&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;atoi&nbsp;(&nbsp;tok&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;r&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;t;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;tok&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;strtok&nbsp;(&nbsp;NULL,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;atoi&nbsp;(&nbsp;tok&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;t;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1.0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;r;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%.2lf\n</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1.0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;res&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}<br></span></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p></span></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/131671.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-28 22:23 <a href="http://www.cppblog.com/MiYu/archive/2010/10/28/131671.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1098 HDOJ 1098 Ignatius's puzzle ACM 1098 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/10/28/131663.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Thu, 28 Oct 2010 13:17:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/28/131663.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131663.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/28/131663.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131663.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131663.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8"><span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; line-height: normal; font-size: 13px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp; &nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目地址:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp;&nbsp;<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1098">http://acm.hdu.edu.cn/showproblem.php?pid=1098</a></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目分析:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; 纯粹的数学题, 数学归纳法的 应用 &nbsp;, 最后 归纳得出 &nbsp;原题等价与 18 + k*a 是否能被65整除.</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">代码如下 :</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_585196d1-488d-484d-9bfa-f882110f0a05" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; font-family: 'Courier New'; ">代码</span><div id="cnblogs_code_open_585196d1-488d-484d-9bfa-f882110f0a05"><div><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_1098<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;Ignatius's&nbsp;puzzle<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br>inline&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">bool</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;scan_d(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">num)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">char</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">bool</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;IsN</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">getchar();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">EOF)&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">||</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">9</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">))&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">getchar();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">){&nbsp;IsN</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">true</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;num</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;num</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">getchar(),</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">9</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;num</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">10</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,num</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(IsN)&nbsp;num</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">num;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">true</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;scan_d&nbsp;(&nbsp;N&nbsp;)&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;N&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">%</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">65</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">no</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">65</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;(&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">18</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">%</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">65</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d\n</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;i&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">break</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">65</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;puts&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">no</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}<br></span></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p></span></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/131663.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-28 21:17 <a href="http://www.cppblog.com/MiYu/archive/2010/10/28/131663.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1230 HDOJ 1230 火星A+B ACM 1230 IN HDU </title><link>http://www.cppblog.com/MiYu/archive/2010/10/28/131654.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Thu, 28 Oct 2010 11:46:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/28/131654.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131654.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/28/131654.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131654.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131654.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8"><span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;题目地址:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<a href="http://acm.hdu.edu.cn/showproblem.php?pid=1230">http://acm.hdu.edu.cn/showproblem.php?pid=1230</a></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目描述:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; &nbsp; &nbsp;纯粹的模拟题........</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">代码:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;<span  style="font-family: 'Courier New'; font-size: 13px; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_f0ef5983-f52e-4136-98b4-9bd871aafe3a" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; ">代码</span></span></p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "><div id="cnblogs_code_open_f0ef5983-f52e-4136-98b4-9bd871aafe3a"><div><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a,&nbsp;b;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;prim[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">40</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;{</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">3</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">5</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">7</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">11</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">13</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">17</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">19</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">23</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">29</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">31</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">37</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">41</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">43</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">47</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">53</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">59</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">61</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">67</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">71</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">73</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">79</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">83</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">89</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">97</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">101</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">103</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">107</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">109</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">113</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">};<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">30</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">],&nbsp;y[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">30</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;cin&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b,&nbsp;a&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset&nbsp;(&nbsp;x,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(x)&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset&nbsp;(&nbsp;y,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(y)&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;k&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a.size();&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;a[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x[j]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x[j]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">10</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b.size();&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;b[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y[k]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;y[k]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">10</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">0</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;k;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse&nbsp;(&nbsp;x</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;x&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse&nbsp;(&nbsp;y</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;y&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;k&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;f&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;m&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;mm&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;k;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;t&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;m&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;mm&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap&nbsp;(&nbsp;m,&nbsp;mm&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">cout&nbsp;&lt;&lt;&nbsp;m&nbsp;&lt;&lt;&nbsp;"&nbsp;"&nbsp;&lt;&lt;&nbsp;mm&nbsp;&lt;&lt;&nbsp;endl;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;z[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">30</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;m;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;y[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;f;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;prim[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">%=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;prim[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[m</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;m&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;mm;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;temp&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">!</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">t&nbsp;)&nbsp;temp&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;y[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">else</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;temp&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;temp&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;f;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;prim[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">%=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;prim[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;f&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z[</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">mm]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;f;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;mm;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">--</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;mm&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">?</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">,%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,z[i]&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;putchar&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">10</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}</span></div></div></div></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/131654.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-28 19:46 <a href="http://www.cppblog.com/MiYu/archive/2010/10/28/131654.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 2689 HDOJ 2689 Sort it ACM 2689 IN HDU </title><link>http://www.cppblog.com/MiYu/archive/2010/10/27/131506.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Wed, 27 Oct 2010 07:23:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/27/131506.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131506.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/27/131506.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131506.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131506.html</trackback:ping><description><![CDATA[<span  style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目地址 :</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://acm.hdu.edu.cn/showproblem.php?pid=2689">&nbsp;http://acm.hdu.edu.cn/showproblem.php?pid=2689&nbsp;</a></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">题目描述:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;&nbsp; 其实就是求 冒泡排序时 的交换次数, &nbsp;当然也可以求逆序数来解决问题, 下面是2份 代码:</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_088c1207-98d6-4d06-b962-93bbb10457cb" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; font-family: 'Courier New'; ">代码</span><div id="cnblogs_code_open_088c1207-98d6-4d06-b962-93bbb10457cb"><div><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">直接冒泡排序求交换的次数</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_2689<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;Sort&nbsp;it<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N,&nbsp;num[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1010</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br>inline&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;swap&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">a,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">b&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">^=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">^=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">^=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;b;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;bouble&nbsp;()&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;j&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;num[j</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;num[j]&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap&nbsp;(&nbsp;num[j</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">],&nbsp;num[j]&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;print&nbsp;()&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;num[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;endl;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">N&nbsp;)&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;num&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d\n</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,bouble&nbsp;()&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;print&nbsp;();</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}<br><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">树状数组求逆序数法</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_2689<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;Sort&nbsp;it<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N,val,num[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1010</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">],low[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1010</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;init&nbsp;()&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1010</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;low[i]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">i&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;modify&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;x&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;num[x];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;low[x];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;query&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;x&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;x&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;num[x];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;low[x];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum;<br>}<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;init&nbsp;();<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">N&nbsp;)&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">==</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset&nbsp;(&nbsp;num,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;num&nbsp;)&nbsp;);&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;sum&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">val&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modify&nbsp;(&nbsp;val&nbsp;);&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;query&nbsp;(&nbsp;val&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;);&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d\n</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;sum&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}</span></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p></span>
<img src ="http://www.cppblog.com/MiYu/aggbug/131506.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-27 15:23 <a href="http://www.cppblog.com/MiYu/archive/2010/10/27/131506.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 2561 HDOJ 2561 第二小整数 ACM 2561 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/10/25/131236.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Mon, 25 Oct 2010 13:59:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/25/131236.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131236.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/25/131236.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131236.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131236.html</trackback:ping><description><![CDATA[<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">没事水题,</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;<span  style="font-family: 'Courier New'; font-size: 13px; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_2749de79-09b0-47a5-a9ef-4e2fbd193ac9" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; ">代码</span></span></p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><div id="cnblogs_code_open_2749de79-09b0-47a5-a9ef-4e2fbd193ac9"><div><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">/*</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Mail&nbsp;to&nbsp;&nbsp;&nbsp;:&nbsp;miyubai@gamil.com<br>My&nbsp;Blog&nbsp;&nbsp;&nbsp;:&nbsp;www.baiyun.me<br>Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cnblogs.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">&nbsp;&nbsp;||&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); text-decoration: underline; ">http://www.cppblog.com/MiYu</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br>Author&nbsp;By&nbsp;:&nbsp;MiYu<br>Test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1<br>Complier&nbsp;&nbsp;:&nbsp;g++&nbsp;mingw32-3.4.2<br>Program&nbsp;&nbsp;&nbsp;:&nbsp;HDU_2561<br>Doc&nbsp;Name&nbsp;&nbsp;:&nbsp;第二小整数&nbsp;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">*/</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">//</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); ">#pragma&nbsp;warning(&nbsp;disable:4789&nbsp;)</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">iostream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">fstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">sstream</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">algorithm</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">string</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">set</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">map</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">utility</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">queue</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">stack</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">list</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">vector</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdio</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstdlib</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cstring</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">cmath</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>#include&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ctime</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">using</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">namespace</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;std;&nbsp;<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;a[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">20</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br></span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;main&nbsp;()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;T;<br>&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">T&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;T&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">--</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&amp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">N&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;&nbsp;i&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;N;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">++</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i&nbsp;)&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;a</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">i&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sort&nbsp;(&nbsp;a,&nbsp;a</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">N&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;(&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">%d\n</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">"</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">,&nbsp;a[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">return</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>}</span></div></div></div>
<img src ="http://www.cppblog.com/MiYu/aggbug/131236.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-25 21:59 <a href="http://www.cppblog.com/MiYu/archive/2010/10/25/131236.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>HDU 1512 HDOJ 1512 Monkey King ( 左偏树 ) ACM 1512 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/10/24/131043.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sun, 24 Oct 2010 03:43:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/24/131043.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131043.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/24/131043.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131043.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131043.html</trackback:ping><description><![CDATA[<p>MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p>&nbsp;</p><p>题目地址:</p><p><a href="http://acm.hdu.edu.cn/showproblem.php?pid=1512">http://acm.hdu.edu.cn/showproblem.php?pid=1512</a></p><p>题目描述 :</p><div class="cnblogs_code" onclick="cnblogs_code_show('93ce2b86-12de-4b7c-b5b1-c014e2356326')"><img src="http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" class="code_img_closed" id="code_img_closed_93ce2b86-12de-4b7c-b5b1-c014e2356326" alt=""><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_93ce2b86-12de-4b7c-b5b1-c014e2356326" onclick="cnblogs_code_hide('93ce2b86-12de-4b7c-b5b1-c014e2356326',event)" style="display:none"><span class="cnblogs_code_collapse">代码</span><div id="cnblogs_code_open_93ce2b86-12de-4b7c-b5b1-c014e2356326" class="cnblogs_code_hide"><div><!--<br/ /><br/ />Code highlighting produced by Actipro CodeHighlighter (freeware)<br/ />http://www.CodeHighlighter.com/<br/ /><br/ />--><span style="color: #000000;">Monkey&nbsp;King<br><br>Time&nbsp;Limit:&nbsp;</span><span style="color: #800080;">10000</span><span style="color: #000000;">/</span><span style="color: #800080;">5000</span><span style="color: #000000;">&nbsp;MS&nbsp;(Java</span><span style="color: #000000;">/</span><span style="color: #000000;">Others)&nbsp;&nbsp;&nbsp;&nbsp;Memory&nbsp;Limit:&nbsp;</span><span style="color: #800080;">65536</span><span style="color: #000000;">/</span><span style="color: #800080;">32768</span><span style="color: #000000;">&nbsp;K&nbsp;(Java</span><span style="color: #000000;">/</span><span style="color: #000000;">Others)<br>Total&nbsp;Submission(s):&nbsp;</span><span style="color: #800080;">914</span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;Accepted&nbsp;Submission(s):&nbsp;</span><span style="color: #800080;">426</span><span style="color: #000000;"><br><br><br>Problem&nbsp;Description<br>Once&nbsp;</span><span style="color: #0000FF;">in</span><span style="color: #000000;">&nbsp;a&nbsp;forest,&nbsp;there&nbsp;lived&nbsp;N&nbsp;aggressive&nbsp;monkeys.&nbsp;At&nbsp;the&nbsp;beginning,&nbsp;they&nbsp;each&nbsp;does&nbsp;things&nbsp;</span><span style="color: #0000FF;">in</span><span style="color: #000000;">&nbsp;its&nbsp;own&nbsp;way&nbsp;and&nbsp;none&nbsp;of&nbsp;them&nbsp;knows&nbsp;each&nbsp;other.&nbsp;But&nbsp;monkeys&nbsp;can</span><span style="color: #800000;">'</span><span style="color: #800000;">t&nbsp;avoid&nbsp;quarrelling,&nbsp;and&nbsp;it&nbsp;only&nbsp;happens&nbsp;between&nbsp;two&nbsp;monkeys&nbsp;who&nbsp;does&nbsp;not&nbsp;know&nbsp;each&nbsp;other.&nbsp;And&nbsp;when&nbsp;it&nbsp;happens,&nbsp;both&nbsp;the&nbsp;two&nbsp;monkeys&nbsp;will&nbsp;invite&nbsp;the&nbsp;strongest&nbsp;friend&nbsp;of&nbsp;them,&nbsp;and&nbsp;duel.&nbsp;Of&nbsp;course,&nbsp;after&nbsp;the&nbsp;duel,&nbsp;the&nbsp;two&nbsp;monkeys&nbsp;and&nbsp;all&nbsp;of&nbsp;there&nbsp;friends&nbsp;knows&nbsp;each&nbsp;other,&nbsp;and&nbsp;the&nbsp;quarrel&nbsp;above&nbsp;will&nbsp;no&nbsp;longer&nbsp;happens&nbsp;between&nbsp;these&nbsp;monkeys&nbsp;even&nbsp;if&nbsp;they&nbsp;have&nbsp;ever&nbsp;conflicted.</span><span style="color: #800000;"><br></span><span style="color: #000000;"><br>Assume&nbsp;that&nbsp;every&nbsp;money&nbsp;has&nbsp;a&nbsp;strongness&nbsp;value,&nbsp;which&nbsp;will&nbsp;be&nbsp;reduced&nbsp;to&nbsp;only&nbsp;half&nbsp;of&nbsp;the&nbsp;original&nbsp;after&nbsp;a&nbsp;duel(that&nbsp;</span><span style="color: #0000FF;">is</span><span style="color: #000000;">,&nbsp;</span><span style="color: #800080;">10</span><span style="color: #000000;">&nbsp;will&nbsp;be&nbsp;reduced&nbsp;to&nbsp;</span><span style="color: #800080;">5</span><span style="color: #000000;">&nbsp;and&nbsp;</span><span style="color: #800080;">5</span><span style="color: #000000;">&nbsp;will&nbsp;be&nbsp;reduced&nbsp;to&nbsp;</span><span style="color: #800080;">2</span><span style="color: #000000;">).<br><br>And&nbsp;we&nbsp;also&nbsp;assume&nbsp;that&nbsp;every&nbsp;monkey&nbsp;knows&nbsp;himself.&nbsp;That&nbsp;</span><span style="color: #0000FF;">is</span><span style="color: #000000;">,&nbsp;when&nbsp;he&nbsp;</span><span style="color: #0000FF;">is</span><span style="color: #000000;">&nbsp;the&nbsp;strongest&nbsp;one&nbsp;</span><span style="color: #0000FF;">in</span><span style="color: #000000;">&nbsp;all&nbsp;of&nbsp;his&nbsp;friends,&nbsp;he&nbsp;himself&nbsp;will&nbsp;go&nbsp;to&nbsp;duel.<br>&nbsp;<br><br>Input<br>There&nbsp;are&nbsp;several&nbsp;test&nbsp;cases,&nbsp;and&nbsp;each&nbsp;</span><span style="color: #0000FF;">case</span><span style="color: #000000;">&nbsp;consists&nbsp;of&nbsp;two&nbsp;parts.<br><br>First&nbsp;part:&nbsp;The&nbsp;first&nbsp;line&nbsp;contains&nbsp;an&nbsp;integer&nbsp;N(N</span><span style="color: #000000;">&lt;=</span><span style="color: #800080;">100</span><span style="color: #000000;">,</span><span style="color: #800080;">000</span><span style="color: #000000;">),&nbsp;which&nbsp;indicates&nbsp;the&nbsp;number&nbsp;of&nbsp;monkeys.&nbsp;And&nbsp;then&nbsp;N&nbsp;lines&nbsp;follows.&nbsp;There&nbsp;</span><span style="color: #0000FF;">is</span><span style="color: #000000;">&nbsp;one&nbsp;number&nbsp;on&nbsp;each&nbsp;line,&nbsp;indicating&nbsp;the&nbsp;strongness&nbsp;value&nbsp;of&nbsp;ith&nbsp;monkey(</span><span style="color: #000000;">&lt;=</span><span style="color: #800080;">32768</span><span style="color: #000000;">).<br><br>Second&nbsp;part:&nbsp;The&nbsp;first&nbsp;line&nbsp;contains&nbsp;an&nbsp;integer&nbsp;M(M</span><span style="color: #000000;">&lt;=</span><span style="color: #800080;">100</span><span style="color: #000000;">,</span><span style="color: #800080;">000</span><span style="color: #000000;">),&nbsp;which&nbsp;indicates&nbsp;there&nbsp;are&nbsp;M&nbsp;conflicts&nbsp;happened.&nbsp;And&nbsp;then&nbsp;M&nbsp;lines&nbsp;follows,&nbsp;each&nbsp;line&nbsp;of&nbsp;which&nbsp;contains&nbsp;two&nbsp;integers&nbsp;x&nbsp;and&nbsp;y,&nbsp;indicating&nbsp;that&nbsp;there&nbsp;</span><span style="color: #0000FF;">is</span><span style="color: #000000;">&nbsp;a&nbsp;conflict&nbsp;between&nbsp;the&nbsp;Xth&nbsp;monkey&nbsp;and&nbsp;Yth.<br><br>&nbsp;<br><br>Output<br>For&nbsp;each&nbsp;of&nbsp;the&nbsp;conflict,&nbsp;output&nbsp;</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000FF;">if</span><span style="color: #000000;">&nbsp;the&nbsp;two&nbsp;monkeys&nbsp;know&nbsp;each&nbsp;other,&nbsp;otherwise&nbsp;output&nbsp;the&nbsp;strongness&nbsp;value&nbsp;of&nbsp;the&nbsp;strongest&nbsp;monkey&nbsp;</span><span style="color: #0000FF;">in</span><span style="color: #000000;">&nbsp;all&nbsp;friends&nbsp;of&nbsp;them&nbsp;after&nbsp;the&nbsp;duel.<br>&nbsp;<br><br>Sample&nbsp;Input<br></span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #800080;">20</span><span style="color: #000000;"><br></span><span style="color: #800080;">16</span><span style="color: #000000;"><br></span><span style="color: #800080;">10</span><span style="color: #000000;"><br></span><span style="color: #800080;">10</span><span style="color: #000000;"><br></span><span style="color: #800080;">4</span><span style="color: #000000;"><br></span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #800080;">2</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">3</span><span style="color: #000000;"><br></span><span style="color: #800080;">3</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">4</span><span style="color: #000000;"><br></span><span style="color: #800080;">3</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #800080;">4</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #800080;">1</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">5</span><span style="color: #000000;"><br>&nbsp;<br><br>Sample&nbsp;Output<br></span><span style="color: #800080;">8</span><span style="color: #000000;"><br></span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #800080;">5</span><span style="color: #000000;"><br></span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;"><br></span><span style="color: #800080;">10</span><span style="color: #000000;"><br>&nbsp;<br></span></div></div></div><p>&nbsp;</p><p>&nbsp;</p><p>题目分析:</p><div class="cnblogs_code"><div><font  color="#800080"><div><div>/*</div><div>Mail to &nbsp; : miyubai@gamil.com</div><div>My Blog &nbsp; : www.baiyun.me</div><div>Link &nbsp; &nbsp; &nbsp;: http://www.cnblogs.com/MiYu &nbsp;|| http://www.cppblog.com/MiYu</div><div>Author By : MiYu</div><div>Test &nbsp; &nbsp; &nbsp;: 1</div><div>Complier &nbsp;: g++ mingw32-3.4.2</div><div>Program &nbsp; : HDU_1512</div><div>Doc Name &nbsp;: Monkey King</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;</div><div>题目意思:&nbsp;</div><div><br></div><div>有N只猴子, 每只都有一个力量值. 开始的时候互不认识, 它们之间会发生M次斗争. 每次发生a, b的斗争时, a, b都会从各自的朋友圈里拉出一个最强的, 之后两只猴子打, 打完后这两只猴子的力量值各减半. 并且打完后, 两只猴子的朋友圈的所有人都互相认识(也就是不会再打).</div><div><br></div><div>你的任务就是对于每个斗争, 若a, b是朋友, 那么输出-1, 否则输出打完后它们的朋友圈的最强猴子的力量值.</div><div><br></div><div>&nbsp;使用 普通 优先队列的话 估计会超时, 因为数据量很大 100000 ! !, 等下有空试试看.&nbsp;</div><div><br></div><div>对于每一个节点, 定义dis 表示X节点到最右边的空节点的距离的最小值</div><div><br></div><div>对于每个节点X, 要求X的左儿子的dis &gt;= 右儿子的dis, 那么容易发现, 对于N个节点的左偏树, 其右儿子最多只有logN个节点.</div><div><br></div><div>合并操作就是让复杂度落在右儿子上, 从而达到logN的合并复杂度.</div><div><br></div><div>首先对于两个堆, 若其中一个为空, 返回另一个.</div><div><br></div><div>否则(这里以大根堆为例), a指向堆顶较大的堆, b指向另一个. 让a的右儿子和b合并, 合并后的子树作为a的右儿子.</div><div><br></div><div>接下来, 检查a的两个儿子是否满足dis, 不满足就交换两个儿子.</div><div><br></div><div>最后, 更新a的dis.</div><div><br></div><div>这样就容易实现堆的其他操作 ( 比如插入, 删除顶等 ).</div><div><br></div><div>另外 还需要用到 并查集. &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;</div><div>*/</div><div>//#pragma warning( disable:4789 )</div><div>#include &lt;iostream&gt;</div><div>#include &lt;fstream&gt;</div><div>#include &lt;sstream&gt;</div><div>#include &lt;algorithm&gt;</div><div>#include &lt;string&gt;</div><div>#include &lt;set&gt;</div><div>#include &lt;map&gt;</div><div>#include &lt;utility&gt;</div><div>#include &lt;queue&gt;</div><div>#include &lt;stack&gt;</div><div>#include &lt;list&gt;</div><div>#include &lt;vector&gt;</div><div>#include &lt;cstdio&gt;</div><div>#include &lt;cstdlib&gt;</div><div>#include &lt;cstring&gt;</div><div>#include &lt;cmath&gt;</div><div>#include &lt;ctime&gt;</div><div>using namespace std;</div><div>const int MM = 100010;</div><div>struct left {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int l,r,dis,val,dad;</div><div>} heap[MM];</div><div><br></div><div>int N, M;</div><div><br></div><div>inline int max ( const int &amp;a, const int &amp;b) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; return a &gt; b ? a : b;</div><div>}</div><div><br></div><div>inline int find ( int &amp;x ) {</div><div>&nbsp;&nbsp; &nbsp;return heap[x].dad == x ? x : heap[x].dad = find ( heap[x].dad );</div><div>}</div><div><br></div><div>inline void swap(int &amp;a, int &amp;b) {</div><div>&nbsp;&nbsp; &nbsp; a ^= b ^= a ^= b;</div><div>}</div><div><br></div><div>inline int merge ( int x, int y ) {</div><div>&nbsp;&nbsp; &nbsp;if ( x == 0 ) return y;</div><div>&nbsp;&nbsp; &nbsp;if ( y == 0 ) return x;</div><div>&nbsp;&nbsp; &nbsp;if ( heap[y].val &gt; heap[x].val ) swap ( x, y ); &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;heap[x].r = merge ( heap[x].r, y );</div><div>&nbsp;&nbsp; &nbsp;heap[heap[x].r].dad = x;</div><div>&nbsp;&nbsp; &nbsp;if ( heap[ heap[x].l ].dis &lt; heap[ heap[x].r ].dis )&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; swap ( heap[x].l, heap[x].r );</div><div>&nbsp;&nbsp; &nbsp;if ( heap[x].r == 0 ) heap[x].dis = 0;</div><div>&nbsp;&nbsp; &nbsp;else heap[x].dis = heap[ heap[x].r ].dis + 1;</div><div>&nbsp;&nbsp; &nbsp;return x;</div><div>}</div><div><br></div><div>inline int push ( int x, int y ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; return merge ( x, y ); &nbsp; &nbsp; &nbsp;&nbsp;</div><div>}</div><div><br></div><div>inline int pop ( int &amp;x ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; int l = heap[x].l;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; int r = heap[x].r;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; heap[l].dad = l;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; heap[r].dad = r;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; heap[x].l = heap[x].r = heap[x].dis = 0; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; return merge ( l, r ); &nbsp;</div><div>}</div><div><br></div><div>inline bool scan_d(int &amp;num) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char in;bool IsN=false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;in=getchar();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(in==EOF) return false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(in!='-'&amp;&amp;(in&lt;'0'||in&gt;'9')) in=getchar();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(in=='-'){ IsN=true;num=0;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else num=in-'0';</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;while(in=getchar(),in&gt;='0'&amp;&amp;in&lt;='9'){</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;num*=10,num+=in-'0';</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if(IsN) num=-num;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return true;</div><div>}</div><div><br></div><div>int main() {</div><div>&nbsp;&nbsp; &nbsp;while ( scan_d ( N ) ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; for ( int i = 1; i &lt;= N; ++ i ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scan_d ( heap[i].val );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heap[i].l = heap[i].r = heap[i].dis = 0;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heap[i].dad = i; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; scan_d ( M );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; int a, b, x, y;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; while ( M -- ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scan_d (a); scan_d (b);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x = find ( a );</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y = find ( b );&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( x == y ) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;puts ( "-1" ); &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heap[x].val /= 2;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int xx = push ( pop ( x ), x ); &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;heap[y].val /= 2;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int yy = push ( pop ( y ), y ); &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf ( "%d\n", heap[ merge ( xx, yy ) ].val ); &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;</div><div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;return 0;</div><div>}</div></div><div><br></div><div><br></div></font></div></div><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><img src ="http://www.cppblog.com/MiYu/aggbug/131043.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-24 11:43 <a href="http://www.cppblog.com/MiYu/archive/2010/10/24/131043.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>左偏树详解 ( 转载 )</title><link>http://www.cppblog.com/MiYu/archive/2010/10/24/131040.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sun, 24 Oct 2010 02:53:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/24/131040.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131040.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/24/131040.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131040.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131040.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MiYu原创, 转帖请注明 : 转载自&nbsp;______________白白の屋&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.1.2&nbsp;可并堆的定义可并堆(Mergeable Heap)也是一种抽象数据类型，它除了支持优先队列的三个基本操作(Insert, Minimum, Delete-Min)，还支持一个额外的操作——合并操作：H &#8592; Merge(H...&nbsp;&nbsp;<a href='http://www.cppblog.com/MiYu/archive/2010/10/24/131040.html'>阅读全文</a><img src ="http://www.cppblog.com/MiYu/aggbug/131040.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-24 10:53 <a href="http://www.cppblog.com/MiYu/archive/2010/10/24/131040.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Bellman-Ford &amp;&amp; SPFA 算法</title><link>http://www.cppblog.com/MiYu/archive/2010/10/23/131018.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sat, 23 Oct 2010 14:09:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/23/131018.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131018.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/23/131018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131018.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131018.html</trackback:ping><description><![CDATA[<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><div><font  color="#800080"><span  style="font-family: sans-serif; color: rgb(0, 0, 0); line-height: 19px; "><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; ">&nbsp;B-F&nbsp;</h2><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; "><span class="mw-headline" style="font-family: 'Courier New'; ">适用条件&amp;范围</span></p><ol style="line-height: 1.5em; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 3.2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: none; "><li style="margin-bottom: 0.1em; ">单源最短路径(从源点s到其它所有顶点v);</li><li style="margin-bottom: 0.1em; ">有向图&amp;无向图(无向图可以看作(u,v),(v,u)同属于边集E的有向图);</li><li style="margin-bottom: 0.1em; ">边权可正可负(如有负权回路输出错误提示);</li><li style="margin-bottom: 0.1em; ">差分约束系统;</li></ol><a name=".E7.AE.97.E6.B3.95.E6.8F.8F.E8.BF.B0" style="text-decoration: none; color: rgb(0, 43, 184); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.cnblogs.com/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; "><span class="mw-headline" style="font-family: 'Courier New'; ">算法描述</span></h2><ol style="line-height: 1.5em; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 3.2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: none; "><li style="margin-bottom: 0.1em; ">对每条边进行|V|-1次Relax ( 就是松弛操作 )操作;</li><li style="margin-bottom: 0.1em; ">如果存在(u,v)&#8712;E使得dis[u]+w&lt;dis[v],则存在负权回路;否则dis[v]即为s到v的最短距离,pre[v]为前驱。</li></ol><pre style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; ">For i:=1 to |V|-1 do //v为顶点数
For 每条边(u,v)&#8712;E do  //对每条边进行遍历
  Relax(u,v,w);
For每条边(u,v)&#8712;E do
  If dis[u]+w&lt;dis[v] Then Exit(False)
</pre><a name=".E6.97.B6.E7.A9.BA.E5.A4.8D.E6.9D.82.E5.BA.A6" style="text-decoration: none; color: rgb(0, 43, 184); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.cnblogs.com/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; "><span class="mw-headline" style="font-family: 'Courier New'; ">时空复杂度</span></h2><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">算法时间复杂度O(VE)。因为算法简单，适用范围又广，虽然复杂度稍高，仍不失为一个很实用的算法。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">算法的改进---&gt; SPFA&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; ">&nbsp;</p><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; "><span class="mw-headline" style="font-family: 'Courier New'; ">算法简介</span></h2><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">SPFA(Shortest Path Faster Algorithm)是<a href="http://www.nocow.cn/index.php/Bellman-Ford%E7%AE%97%E6%B3%95" title="Bellman-Ford算法" style="text-decoration: none; color: rgb(90, 54, 150); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; ">Bellman-Ford算法</a>的一种<a href="http://www.nocow.cn/index.php/%E9%98%9F%E5%88%97" title="队列" style="text-decoration: none; color: rgb(0, 43, 184); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; ">队列</a>实现，减少了不必要的冗余计算。也有人说SPFA本来就是Bellman-Ford算法，现在广为流传的<a href="http://www.nocow.cn/index.php/Bellman-Ford%E7%AE%97%E6%B3%95" title="Bellman-Ford算法" style="text-decoration: none; color: rgb(90, 54, 150); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; ">Bellman-Ford算法</a>实际上是山寨版。</p><a name=".E7.AE.97.E6.B3.95.E6.B5.81.E7.A8.8B" style="text-decoration: none; color: rgb(0, 43, 184); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.cnblogs.com/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; "><span class="mw-headline" style="font-family: 'Courier New'; ">算法流程</span></h2><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">算法大致流程是用一个队列来进行维护。 初始时将源加入队列。 每次从队列中取出一个元素，并对所有与他相邻的点进行<a href="http://www.nocow.cn/index.php/%E6%9D%BE%E5%BC%9B" title="松弛" style="text-decoration: none; color: rgb(0, 43, 184); background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; ">松弛</a>，若某个相邻的点松弛成功，则将其入队。 直到队列为空时算法结束。</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">这个算法，简单的说就是队列优化的bellman-ford,利用了每个点不会更新次数太多的特点发明的此算法</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">SPFA——Shortest Path Faster Algorithm，它可以在O(kE)的时间复杂度内求出源点到其他所有点的最短路径，可以处理负边。SPFA的实现甚至比Dijkstra或者Bellman_Ford还要简单：</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">设Dist代表S到I点的当前最短距离，Fa代表S到I的当前最短路径中I点之前的一个点的编号。开始时Dist全部为+&#8734;，只有Dist[S]=0，Fa全部为0。</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">维护一个队列，里面存放所有需要进行迭代的点。初始时队列中只有一个点S。用一个布尔数组记录每个点是否处在队列中。</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">每次迭代，取出队头的点v，依次枚举从v出发的边v-&gt;u，设边的长度为len，判断Dist[v]+len是否小于Dist[u]，若小于则改进Dist[u]，将Fa[u]记为v，并且由于S到u的最短距离变小了，有可能u可以改进其它的点，所以若u不在队列中，就将它放入队尾。这样一直迭代下去直到队列变空，也就是S到所有的最短距离都确定下来，结束算法。若一个点入队次数超过n，则有负权环。</p><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; ">SPFA 在形式上和宽度优先搜索非常类似，不同的是宽度优先搜索中一个点出了队列就不可能重新进入队列，但是SPFA中一个点可能在出队列之后再次被放入队列，也就是一个点改进过其它的点之后，过了一段时间可能本身被改进，于是再次用来改进其它的点，这样反复迭代下去。设一个点用来作为迭代点对其它点进行改进的平均次数为k，有办法证明对于通常的情况，k在2左右</p><a name=".E7.AE.97.E6.B3.95.E4.BB.A3.E7.A0.81" style="text-decoration: none; color: rgb(0, 43, 184); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.cnblogs.com/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><h2 style="color: black; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-weight: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0.6em; margin-left: 0px; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); font-size: 19px; "><span class="mw-headline" style="font-family: 'Courier New'; ">算法代码</span></h2><pre class="pascal" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; "><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">Procedure</span> SPFA;
&nbsp;
<span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">Begin</span>
  initialize-single-source<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>G,s<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
  initialize-queue<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>Q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
  enqueue<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>Q,s<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
  <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">while</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">not</span> empty<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>Q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">do</span> 
    <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
      u:=dequeue<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>Q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
      <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">for</span> each v&#8712;adj<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>u<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">do</span> 
        <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
          tmp:=d<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>;
          relax<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>u,v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
          <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">if</span> <span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>tmp&lt;&gt;d<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; ">and</span> <span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span><span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">not</span> v <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">in</span> Q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">then</span>
            enqueue<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>Q,v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
        <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;
    <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;
<span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">End</span>;</pre><p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 0px; line-height: 1.5em; "><br></p><pre class="pascal" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; "><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">procedure</span> spfa;
<span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
  fillchar<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>q,sizeof<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>,<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">0</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>; h:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">0</span>; t:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">0</span>;<span style="font-family: 'Courier New'; color: rgb(128, 128, 128); font-style: italic; ">//队列</span>
  fillchar<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>v,sizeof<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>,<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">false</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;<span style="font-family: 'Courier New'; color: rgb(128, 128, 128); font-style: italic; ">//v[i]判断i是否在队列中</span>
  <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">for</span> i:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">1</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">to</span> n <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">do</span> 
    dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=maxint;<span style="font-family: 'Courier New'; color: rgb(128, 128, 128); font-style: italic; ">//初始化最小值</span>
&nbsp;
  inc<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>t<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span>;
  q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>t<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">1</span>;
  v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span><span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">1</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">true</span>;
  dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span><span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">1</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">0</span>;<span style="font-family: 'Courier New'; color: rgb(128, 128, 128); font-style: italic; ">//这里把1作为源点</span>
&nbsp;
  <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">while</span> h&lt;&gt;t <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">do</span>
    <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
      h:=<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>h <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">mod</span> n<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span><span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">+1</span>;
      x:=q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>h<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>;
      v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">false</span>;
      <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">for</span> i:=<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">1</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">to</span> n <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">do</span>
        <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">if</span> <span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>cost<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x,i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>&gt;<span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">0</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; ">and</span> <span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>+cost<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x,i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>&lt;dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">then</span>
          <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
            dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=dist<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>+cost<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>x,i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>;
            <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">if</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">not</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span><span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span> <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">then</span>
              <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">begin</span>
                t:=<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">(</span>t <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">mod</span> n<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">)</span><span style="font-family: 'Courier New'; color: rgb(204, 102, 204); ">+1</span>;
                q<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>t<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=i;
                v<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(102, 204, 102); ">]</span>:=<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; ">true</span>;
              <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;
          <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;
    <span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;
<span style="font-family: 'Courier New'; color: rgb(177, 177, 0); ">end</span>;</pre><pre class="cpp" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: rgb(47, 111, 171); border-right-color: rgb(47, 111, 171); border-bottom-color: rgb(47, 111, 171); border-left-color: rgb(47, 111, 171); color: black; background-color: rgb(249, 249, 249); line-height: 1.1em; "><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span> SPFA<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">void</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0); ">//好久以前写的&#8230;&#8230;今天丢上来&#8230;&#8230;话说我都不记得SPFA怎么写了&#8230;&#8230;囧&#8230;&#8230;ms存图是矩阵&#8230;&#8230;嗯嗯</span>
<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">{</span>
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span> i;
 queue list;
 list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">insert</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>s<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>;
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>i=<span style="font-family: 'Courier New'; color: rgb(0, 0, 221); ">1</span>;i&lt;=n;i++<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
  <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">{</span>
   <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>s==i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
    <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">continue</span>;
   dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>=map<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>s<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>;
   way<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>=s;
   <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
   list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">insert</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>;
  <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">}</span>
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">int</span> p;
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">while</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>!list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">empty</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">{</span>
  p=list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">fire</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>;
  <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>i=<span style="font-family: 'Courier New'; color: rgb(0, 0, 221); ">1</span>;i&lt;=n;i++<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
   <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>map<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>p<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>&amp;&amp;<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>&gt;dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>p<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>+map<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>p<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>||!dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>&amp;&amp;i!=s<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
    <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">{</span>
     dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>=dist<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>p<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>+map<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>p<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>;
     way<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">[</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span>=p;
     <span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>!list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">in</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>
      list.<span style="font-family: 'Courier New'; color: rgb(0, 238, 255); ">insert</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(</span>i<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">)</span>;
    <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">}</span>
 <span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">}</span>
<span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">}<span  style="font-family: sans-serif; line-height: 19px; white-space: normal; ">&nbsp;</span></span></pre></span></font></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p>
<img src ="http://www.cppblog.com/MiYu/aggbug/131018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-23 22:09 <a href="http://www.cppblog.com/MiYu/archive/2010/10/23/131018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>trie树--详解</title><link>http://www.cppblog.com/MiYu/archive/2010/10/23/131017.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sat, 23 Oct 2010 14:05:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/23/131017.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131017.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/23/131017.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131017.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131017.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MiYu原创, 转帖请注明 : 转载自&nbsp;______________白白の屋&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;文章作者：yx_th000&nbsp;文章来源：Cherish_yimi (http://www.cnblogs.com/cherish_yimi/) 转载请注明，谢谢合作。关键词：trie trie树 数据结构&nbsp;&nbsp;&nbsp;&nb...&nbsp;&nbsp;<a href='http://www.cppblog.com/MiYu/archive/2010/10/23/131017.html'>阅读全文</a><img src ="http://www.cppblog.com/MiYu/aggbug/131017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-23 22:05 <a href="http://www.cppblog.com/MiYu/archive/2010/10/23/131017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>前向星+SPFA(转载)</title><link>http://www.cppblog.com/MiYu/archive/2010/10/23/131014.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Sat, 23 Oct 2010 14:02:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/10/23/131014.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/131014.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/10/23/131014.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/131014.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/131014.html</trackback:ping><description><![CDATA[<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">MiYu原创, 转帖请注明 : 转载自&nbsp;<a href="http://baiyun.me/"><font  color="#000000">______________白白の屋</font></a>&nbsp;&nbsp;<img src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><img src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" class="code_img_opened" id="code_img_opened_44cadeb7-8e99-4853-b65a-0386747ba3d7" style="vertical-align: middle; padding-right: 5px; "><span class="cnblogs_code_collapse" style="border-right-color: rgb(128, 128, 128); border-right-width: 1px; border-right-style: solid; border-top-color: rgb(128, 128, 128); border-top-width: 1px; border-top-style: solid; border-left-color: rgb(128, 128, 128); border-left-width: 1px; border-left-style: solid; border-bottom-color: rgb(128, 128, 128); border-bottom-width: 1px; border-bottom-style: solid; background-color: rgb(255, 255, 255); padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; font-family: 'Courier New'; ">代码</span><div id="cnblogs_code_open_44cadeb7-8e99-4853-b65a-0386747ba3d7"><div><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">前向星</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">SPFA<br>我是在做USACO的sweet&nbsp;butter时偶然发现这个东西的。。。<br>这个算法，简单的说就是队列优化的bellman</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">ford,利用了每个点不会更新次数太多的特点发明的此算法（仅为个人理解</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">.</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">）<br>SPFA——Shortest&nbsp;Path&nbsp;Faster&nbsp;Algorithm，它可以在O(kE)的时间复杂度内求出源点到其他所有点的最短路径，可以处理负边。SPFA的实现甚至比Dijkstra或者Bellman_Ford还要简单：<br>设Dist代表S到I点的当前最短距离，Fa代表S到I的当前最短路径中I点之前的一个点的编号。开始时Dist全部为</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&#8734;，只有Dist[S]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">，Fa全部为0。<br>维护一个队列，里面存放所有需要进行迭代的点。初始时队列中只有一个点S。用一个布尔数组记录每个点是否处在队列中。<br>每次迭代，取出队头的点v，依次枚举从v出发的边v</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">u，设边的长度为len，判断Dist[v]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">len是否小于Dist，若小于则改进Dist，将Fa记为v，并且由于S到u的最短距离变小了，有可能u可以改进其它的点，所以若u不在队列中，就将它放入队尾。这样一直迭代下去直到队列变空，也就是S到所有的最短距离都确定下来，结束算法。<br>SPFA&nbsp;在形式上和宽度优先搜索非常类似，不同的是宽度优先搜索中一个点出了队列就不可能重新进入队列，但是SPFA中一个点可能在出队列之后再次被放入队列，也就是一个点改进过其它的点之后，过了一段时间可能本身被改进，于是再次用来改进其它的点，这样反复迭代下去。设一个点用来作为迭代点对其它点进行改进的平均次数为k，有办法证明对于通常的情况，k在2左右<br>前向星优化：<br>不要把前向星想成什么高深莫测的东西&#8230;&#8230;它其实就是一种邻接表的紧缩存储形式。<br>为什么叫前向星？因为它是将边按照前端点排序，并用一个数组k[i]记录端点i第一次以左端点出现的位置。这样，我们就能用O(E)的空间复杂度存储下一个邻接表，而避免了链表或N</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">^</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">2的庞大空间消耗。<br>当然，实际上我们并不需要排序：因为我们只需要知道某一条边应该放到什么位置即可。因而我们还需要一个数组t[i]存储从i出发的边的条数。则需要存储在的位置就可以很轻易地求得。（详见代码）<br>Butter题目代码如下：<br>Program&nbsp;butter(input,output);<br>Type<br>&nbsp;&nbsp;&nbsp;edge</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">record<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x,y,d:longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>Var<br>&nbsp;&nbsp;&nbsp;min,res,n,p,c,x,y,i,j,l,r:longint;<br>&nbsp;&nbsp;&nbsp;te,e:array[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">..</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">3000</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;of&nbsp;edge;<br>&nbsp;&nbsp;&nbsp;tk,t,k,num,d:array[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">..</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">800</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;of&nbsp;longint;<br>&nbsp;&nbsp;&nbsp;q:array[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">..</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">100000</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;of&nbsp;longint;<br>&nbsp;&nbsp;&nbsp;use:array[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">..</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">800</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;of&nbsp;boolean;<br>Procedure&nbsp;swap(var&nbsp;n1,n2:longint);<br>Var<br>&nbsp;&nbsp;&nbsp;tmp:longint;<br>Begin<br>&nbsp;&nbsp;&nbsp;tmp:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">n1;n1:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">n2;n2:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">tmp;<br>End;<br>Begin<br>&nbsp;&nbsp;&nbsp;assign(input,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">butter.in</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">);reset(input);<br>&nbsp;&nbsp;&nbsp;readln(n,p,c);<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;n&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;read(x);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inc(num[x]);<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;c&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;e[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;readln(x,y,d);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">e[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap(e[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">].x,e[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">].y);<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;c:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">c</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;c&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;inc(t[e[i].x]);<br>&nbsp;&nbsp;&nbsp;j:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;k[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">2</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;p&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k[i]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">k[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">t[i</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">];<br>&nbsp;&nbsp;&nbsp;tk:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">k;te:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">e;<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;c&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e[tk[te[i].x]]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">te[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inc(tk[te[i].x]);<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;min:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">maxlongint;<br>&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;i:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;p&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fillchar(q,</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(q),</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fillchar(d,</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(d),</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">127</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fillchar(use,</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">sizeof</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">(use),</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q[</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">i;l:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;r:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;d[i]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;use[i]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">true</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">k[q[l]]&nbsp;to&nbsp;k[q[l]]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">t[q[l]]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">-</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;d[q[l]]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">e[j].d</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">d[e[j].y]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d[e[j].y]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">d[q[l]]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">e[j].d;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;not&nbsp;use[e[j].y]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use[e[j].y]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">true</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inc(r);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q[r]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">e[j].y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use[q[l]]:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">false</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inc(l);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;l</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&gt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">r;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">0</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">for</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;j:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 128); ">1</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;to&nbsp;p&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">do</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">res</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">+</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">d[j]</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">*</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">num[j];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 255); ">if</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&nbsp;res</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">&lt;</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">min&nbsp;then&nbsp;min:</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">=</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">res;<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;assign(output,</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">butter.out</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0); ">'</span><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">);rewrite(output);<br>&nbsp;&nbsp;&nbsp;writeln(min);close(output);<br>End.<br></span></div></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p>
<img src ="http://www.cppblog.com/MiYu/aggbug/131014.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-10-23 22:02 <a href="http://www.cppblog.com/MiYu/archive/2010/10/23/131014.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>