﻿<?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++博客-Naeioi-随笔分类-题解</title><link>http://www.cppblog.com/Naeioi/category/15384.html</link><description>量子の風</description><language>zh-cn</language><lastBuildDate>Mon, 15 Nov 2010 13:52:33 GMT</lastBuildDate><pubDate>Mon, 15 Nov 2010 13:52:33 GMT</pubDate><ttl>60</ttl><item><title>UVa 10115</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 13:46:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133463.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133463.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133463.html</trackback:ping><description><![CDATA[<a herf="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=1056"><u>原题在这里.</u>小心指针!!!</a><div><a herf="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=1056"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">15</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">300</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">2</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">match</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">k</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">replace</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]= {</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">};</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcat</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcat</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cur</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10115.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10115.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%d"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memset</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">getchar</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">gets</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">N</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">l</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">match</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">key</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">replace</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">puts</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">str</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre></a></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 21:46 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133463.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 644</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 12:32:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133459.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133459.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133459.html</trackback:ping><description><![CDATA[这道题交了4遍才AC,也不懂是什么原因<div><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">20</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">count</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"644.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"644.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%s"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])==</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">'9'</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">continue</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">--</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&amp;&amp;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])&gt;=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">sprintf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%.*s"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strlen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]),</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">j</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">])==</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                        is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">                </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"Set %d is "</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,++</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">count</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">is</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"immediately decodable</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">else</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"not immediately decodable</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=-</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"></pre></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133459.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 20:32 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133459.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 10815</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Fri, 12 Nov 2010 11:13:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133452.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133452.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133452.html</trackback:ping><description><![CDATA[<a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;page=show_problem&amp;problem=1756">原题在这里</a>。代码写的比较乱

<div><a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;page=show_problem&amp;problem=1756"></a><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;cstdio&gt;</span>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;string.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;ctype.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#include &lt;stdlib.h&gt;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">using namespace</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> std</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">5005</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">205</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxn</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">][</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">maxl</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">bool</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">find</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">void</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]))</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return true</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return false</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">cmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">const void</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">b</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">strcmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">((</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*)</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">a</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">char</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*)</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">b</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">main</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">()</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#ifndef ONLINE_JUDGE</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10815.in"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"r"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">freopen</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"10815.out"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"w"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0;">#endif</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#0080c0; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(;;)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">do</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">{</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">getchar</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">();</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">while</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">isalpha</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)&amp;&amp;*</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">!=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">EOF</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">scanf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%[qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM]"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">+</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">1</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)==</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">EOF</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">break</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">];</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]=</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">tolower</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">if</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(!</span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">find</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">())</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">            </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">memcpy</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++],</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">now</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">));</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">qsort</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">sizeof</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]),</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">cmp</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">for</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#8080c0;">int</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">=</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">&lt;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">tot</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">++)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">        </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">printf</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"%s</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff00ff;">\n</span><span style=" font-family:'Courier New'; font-size:10pt; color:#a68500;">"</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">,</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">word</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">[</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">i</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">]);</span></pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080; background-color:#eeeeee;"></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdin</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; color:#004466;">fclose</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">(</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">stdout</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">);</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;">    </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#bb7977;">return</span><span style=" font-family:'Courier New'; font-size:10pt; color:#000000;"> </span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#800080;">0</span><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">;</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"><span style=" font-family:'Courier New'; font-size:10pt; font-weight:600; color:#ff0080;">}</span></pre>
<pre style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#eeeeee;"></pre></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133452.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-12 19:13 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/12/133452.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Uva 409</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Thu, 11 Nov 2010 11:19:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133346.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133346.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133346.html</trackback:ping><description><![CDATA[<a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=96&amp;page=show_problem&amp;problem=350">原题在这里</a>。字符串匹配，写起来稍稍有些繁琐<div><br></div><div><table id="Table1" class="tb" cellspacing="0" cellpadding="3" border="0" style="font-size: 13px; "><tbody><tr><td><pre><div><span style="color: rgb(0, 128, 128); "> 1</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">cstdio</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 2</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 255); ">string</span><span style="color: rgb(0, 0, 0); ">.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 3</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">ctype.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 4</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">vector</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 5</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">using</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">namespace</span><span style="color: rgb(0, 0, 0); "> std;
</span><span style="color: rgb(0, 128, 128); "> 6</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 7</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">const</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> maxk</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">100</span><span style="color: rgb(0, 0, 0); ">,maxl</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">100</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); "> 8</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> key[maxk][maxl],str[maxl],str2[maxl],ans[maxk][maxl];
</span><span style="color: rgb(0, 128, 128); "> 9</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> K,E,n</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,Max,l;
</span><span style="color: rgb(0, 128, 128); ">10</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">11</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">bool</span><span style="color: rgb(0, 0, 0); "> find(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> x,</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> y)
</span><span style="color: rgb(0, 128, 128); ">12</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">13</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">K;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">14</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j;
</span><span style="color: rgb(0, 128, 128); ">15</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">key[i][j];j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">16</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(str[x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j]</span><span style="color: rgb(0, 0, 0); ">!=</span><span style="color: rgb(0, 0, 0); ">key[i][j])
</span><span style="color: rgb(0, 128, 128); ">17</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">break</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">18</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(x</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">j</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">key[i][j])
</span><span style="color: rgb(0, 128, 128); ">19</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">true</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">20</span> <span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">21</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">false</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">22</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">23</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">24</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> main()
</span><span style="color: rgb(0, 128, 128); ">25</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">26</span> <span style="color: rgb(0, 0, 0); ">    #ifndef ONLINE_JUDGE
</span><span style="color: rgb(0, 128, 128); ">27</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">409.in</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">r</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdin);
</span><span style="color: rgb(0, 128, 128); ">28</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">409.out</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">w</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdout);
</span><span style="color: rgb(0, 128, 128); ">29</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">#endif</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">30</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">31</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">K,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">E)</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">2</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">32</span> <span style="color: rgb(0, 0, 0); ">        l</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">Max</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">33</span> <span style="color: rgb(0, 0, 0); ">        printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">Excuse Set #%d\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">n);
</span><span style="color: rgb(0, 128, 128); ">34</span> <span style="color: rgb(0, 0, 0); ">        getchar();
</span><span style="color: rgb(0, 128, 128); ">35</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">36</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">K;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">37</span> <span style="color: rgb(0, 0, 0); ">            gets(key[i]);
</span><span style="color: rgb(0, 128, 128); ">38</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">E;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
</span><span style="color: rgb(0, 128, 128); ">39</span> <span style="color: rgb(0, 0, 0); ">            scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%[^\\r\\n]</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,str);
</span><span style="color: rgb(0, 128, 128); ">40</span> <span style="color: rgb(0, 0, 0); ">            memcpy(str2,str,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">41</span> <span style="color: rgb(0, 0, 0); ">            getchar();
</span><span style="color: rgb(0, 128, 128); ">42</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> a</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,b,count</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">43</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(str[a]){
</span><span style="color: rgb(0, 128, 128); ">44</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">!</span><span style="color: rgb(0, 0, 0); ">isalpha(str[a])</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[a])</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">a;
</span><span style="color: rgb(0, 128, 128); ">45</span> <span style="color: rgb(0, 0, 0); ">                b</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">a;
</span><span style="color: rgb(0, 128, 128); ">46</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(isalpha(str[b])){str[b]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(str[b]);</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">b;}
</span><span style="color: rgb(0, 128, 128); ">47</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(find(a,b</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">))count</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">48</span> <span style="color: rgb(0, 0, 0); ">                a</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">b;
</span><span style="color: rgb(0, 128, 128); ">49</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">50</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">Max){
</span><span style="color: rgb(0, 128, 128); ">51</span> <span style="color: rgb(0, 0, 0); ">                Max</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">count;
</span><span style="color: rgb(0, 128, 128); ">52</span> <span style="color: rgb(0, 0, 0); ">                memset(ans,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(ans));
</span><span style="color: rgb(0, 128, 128); ">53</span> <span style="color: rgb(0, 0, 0); ">                l</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">54</span> <span style="color: rgb(0, 0, 0); ">                memcpy(ans[l</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">],str2,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">55</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">56</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">else</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">Max)
</span><span style="color: rgb(0, 128, 128); ">57</span> <span style="color: rgb(0, 0, 0); ">                    memcpy(ans[l</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">],str2,</span><span style="color: rgb(0, 0, 255); ">sizeof</span><span style="color: rgb(0, 0, 0); ">(str));
</span><span style="color: rgb(0, 128, 128); ">58</span> <span style="color: rgb(0, 0, 0); ">        }
</span><span style="color: rgb(0, 128, 128); ">59</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">l;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">60</span> <span style="color: rgb(0, 0, 0); ">            printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%s\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,ans[i]);
</span><span style="color: rgb(0, 128, 128); ">61</span> <span style="color: rgb(0, 0, 0); ">        printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
</span><span style="color: rgb(0, 128, 128); ">62</span> <span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">63</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">64</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span><span style="color: rgb(0, 128, 128); ">65</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span><span style="color: rgb(0, 128, 128); ">66</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">67</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">68</span> </div></pre></td></tr></tbody></table></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133346.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-11 19:19 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/11/133346.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 537</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Wed, 10 Nov 2010 11:08:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/133228.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/133228.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/133228.html</trackback:ping><description><![CDATA[没什么好说的，锻炼编程能力，注意善用scanf :)<div><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">#include </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">cstdio</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&gt;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 2</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">using</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">namespace</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> std;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 3</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 4</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> N;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 5</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">double</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">260</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">];
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 6</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 7</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "></span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> main()
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 8</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">{
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); "> 9</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    #ifndef ONLINE_JUDGE
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">10</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    freopen(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">537.in</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">r</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,stdin);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">11</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    freopen(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">537.out</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">w</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,stdout);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">12</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">#endif</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">13</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">14</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    scanf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">%d</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">N);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">15</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    getchar();
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">16</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">17</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">for</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">N;i</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">++</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">18</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">19</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">for</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">int</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&lt;=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;j</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">++</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">20</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">char</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> last</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">getchar(),now;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">21</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">while</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">((now</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">getchar())</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">)last</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">now;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">22</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            scanf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">%lf%c</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[last],</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">now);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">23</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">switch</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(now){
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">24</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">m</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">25</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">26</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">27</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">k</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">28</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">29</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">30</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">case</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">M</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">:
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">31</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    a[last]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*=</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">1000000.0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">32</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">break</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">33</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">            }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">34</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">35</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">36</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Problem #%d\\n</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,i);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">37</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">38</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">39</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">           printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P=%.2lfW</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">*</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">40</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">41</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I=%.2lfA</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">42</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">])
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">43</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">                printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">U=%.2lfV</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">,a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">P</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">/</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">a[</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">I</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">'</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">]);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">44</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        printf(</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">\\n\\n</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">45</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    }
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">46</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">47</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">48</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">49</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">;
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">50</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">}
</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 128); ">51</span></span><span  style="font-family: monospace; font-size: 13px; white-space: pre; "> </span></div><img src ="http://www.cppblog.com/Naeioi/aggbug/133228.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-10 19:08 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/10/133228.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UVa 10010</title><link>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html</link><dc:creator>Naeioi Zhu</dc:creator><author>Naeioi Zhu</author><pubDate>Sun, 07 Nov 2010 08:36:00 GMT</pubDate><guid>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html</guid><wfw:comment>http://www.cppblog.com/Naeioi/comments/132866.html</wfw:comment><comments>http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Naeioi/comments/commentRss/132866.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Naeioi/services/trackbacks/132866.html</trackback:ping><description><![CDATA[

<span style="font-family: Arial; font-size: 14px; line-height: 21px; ">&nbsp;&nbsp;在一个n*m的字符矩阵中寻找给定的字符串，字符串可以是上下、下上、左右、右左等8个方向。输出每个字符串第一个字符首次出现的位置。</span><div style="font-family: Arial; font-size: 14px; line-height: 21px; ">要注意的是换行问题，对一个少一个都判作WA</div><div><font color="#008080" face="monospace" size="2"><span style="white-space: pre;"><span  style="color: rgb(0, 0, 0); font-size: 13px; "><span style="color: rgb(0, 128, 128); "> 1</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">cstdio</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 2</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 255); ">string</span><span style="color: rgb(0, 0, 0); ">.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 3</span> <span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">ctype.h</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 4</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">using</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">namespace</span><span style="color: rgb(0, 0, 0); "> std;
</span><span style="color: rgb(0, 128, 128); "> 5</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); "> 6</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">const</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> maxn</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">60</span><span style="color: rgb(0, 0, 0); ">,dx[]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> {</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">},dy[]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> {</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">};
</span><span style="color: rgb(0, 128, 128); "> 7</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> G[maxn][maxn];
</span><span style="color: rgb(0, 128, 128); "> 8</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> N,M,K;
</span><span style="color: rgb(0, 128, 128); "> 9</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">10</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> main()
</span><span style="color: rgb(0, 128, 128); ">11</span> <span style="color: rgb(0, 0, 0); ">{
</span><span style="color: rgb(0, 128, 128); ">12</span> <span style="color: rgb(0, 0, 0); ">#ifndef ONLINE_JUDGE
</span><span style="color: rgb(0, 128, 128); ">13</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">10010.in</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">r</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdin);
</span><span style="color: rgb(0, 128, 128); ">14</span> <span style="color: rgb(0, 0, 0); ">    freopen(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">10010.out</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">w</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,stdout);
</span><span style="color: rgb(0, 128, 128); ">15</span> <span style="color: rgb(0, 0, 0); "></span><span style="color: rgb(0, 0, 255); ">#endif</span><span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">16</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">17</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> C,t</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">18</span> <span style="color: rgb(0, 0, 0); ">    scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">C);
</span><span style="color: rgb(0, 128, 128); ">19</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">20</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(C</span><span style="color: rgb(0, 0, 0); ">--</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">21</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(t</span><span style="color: rgb(0, 0, 0); ">!=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">)printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
</span><span style="color: rgb(0, 128, 128); ">22</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">t;
</span><span style="color: rgb(0, 128, 128); ">23</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">24</span> <span style="color: rgb(0, 0, 0); ">        scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">N,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">M);
</span><span style="color: rgb(0, 128, 128); ">25</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">26</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M; j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">27</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> tmp;
</span><span style="color: rgb(0, 128, 128); ">28</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">do</span><span style="color: rgb(0, 0, 0); "> {
</span><span style="color: rgb(0, 128, 128); ">29</span> <span style="color: rgb(0, 0, 0); ">                    tmp</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">getchar();
</span><span style="color: rgb(0, 128, 128); ">30</span> <span style="color: rgb(0, 0, 0); ">                }
</span><span style="color: rgb(0, 128, 128); ">31</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">!</span><span style="color: rgb(0, 0, 0); ">isalpha(tmp));
</span><span style="color: rgb(0, 128, 128); ">32</span> <span style="color: rgb(0, 0, 0); ">                G[i][j]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(tmp);
</span><span style="color: rgb(0, 128, 128); ">33</span> <span style="color: rgb(0, 0, 0); ">            }
</span><span style="color: rgb(0, 128, 128); ">34</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">35</span> <span style="color: rgb(0, 0, 0); ">        scanf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,</span><span style="color: rgb(0, 0, 0); ">&amp;</span><span style="color: rgb(0, 0, 0); ">K);
</span><span style="color: rgb(0, 128, 128); ">36</span> <span style="color: rgb(0, 0, 0); ">        getchar();
</span><span style="color: rgb(0, 128, 128); ">37</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(K</span><span style="color: rgb(0, 0, 0); ">--</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">38</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> str[maxn];
</span><span style="color: rgb(0, 128, 128); ">39</span> <span style="color: rgb(0, 0, 0); ">            gets(str);
</span><span style="color: rgb(0, 128, 128); ">40</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> len</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">strlen(str);
</span><span style="color: rgb(0, 128, 128); ">41</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">42</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">len; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">43</span> <span style="color: rgb(0, 0, 0); ">                str[i]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">tolower(str[i]);
</span><span style="color: rgb(0, 128, 128); ">44</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">45</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">bool</span><span style="color: rgb(0, 0, 0); "> ok</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 255); ">false</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">46</span> <span style="color: rgb(0, 0, 0); ">            </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">47</span> <span style="color: rgb(0, 0, 0); ">                </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">; j</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; j</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">)
</span><span style="color: rgb(0, 128, 128); ">48</span> <span style="color: rgb(0, 0, 0); ">                    </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> k</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; k</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">8</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;!</span><span style="color: rgb(0, 0, 0); ">ok; k</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">) {
</span><span style="color: rgb(0, 128, 128); ">49</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> x</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">i,y</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">j,count</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">50</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(x</span><span style="color: rgb(0, 0, 0); ">&gt;=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&gt;=</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">x</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">N</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">y</span><span style="color: rgb(0, 0, 0); ">&lt;=</span><span style="color: rgb(0, 0, 0); ">M</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">count</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">len</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[count]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">G[x][y]) {
</span><span style="color: rgb(0, 128, 128); ">51</span> <span style="color: rgb(0, 0, 0); ">                            </span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">count;
</span><span style="color: rgb(0, 128, 128); ">52</span> <span style="color: rgb(0, 0, 0); ">                            x</span><span style="color: rgb(0, 0, 0); ">+=</span><span style="color: rgb(0, 0, 0); ">dx[k];
</span><span style="color: rgb(0, 128, 128); ">53</span> <span style="color: rgb(0, 0, 0); ">                            y</span><span style="color: rgb(0, 0, 0); ">+=</span><span style="color: rgb(0, 0, 0); ">dy[k];
</span><span style="color: rgb(0, 128, 128); ">54</span> <span style="color: rgb(0, 0, 0); ">                        }
</span><span style="color: rgb(0, 128, 128); ">55</span> <span style="color: rgb(0, 0, 0); ">                        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(count</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">len) {
</span><span style="color: rgb(0, 128, 128); ">56</span> <span style="color: rgb(0, 0, 0); ">                            ok</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 255); ">true</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">57</span> <span style="color: rgb(0, 0, 0); ">                            printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">%d %d\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">,i,j);
</span><span style="color: rgb(0, 128, 128); ">58</span> <span style="color: rgb(0, 0, 0); ">                        }
</span><span style="color: rgb(0, 128, 128); ">59</span> <span style="color: rgb(0, 0, 0); ">                    }
</span><span style="color: rgb(0, 128, 128); ">60</span> <span style="color: rgb(0, 0, 0); ">        }
</span><span style="color: rgb(0, 128, 128); ">61</span> <span style="color: rgb(0, 0, 0); ">        </span><span style="color: rgb(0, 128, 0); ">//</span><span style="color: rgb(0, 128, 0); ">printf("\\n");</span><span style="color: rgb(0, 128, 0); ">
</span><span style="color: rgb(0, 128, 128); ">62</span> <span style="color: rgb(0, 128, 0); "></span><span style="color: rgb(0, 0, 0); ">    }
</span><span style="color: rgb(0, 128, 128); ">63</span> <span style="color: rgb(0, 0, 0); ">
</span><span style="color: rgb(0, 128, 128); ">64</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdin);
</span><span style="color: rgb(0, 128, 128); ">65</span> <span style="color: rgb(0, 0, 0); ">    fclose(stdout);
</span><span style="color: rgb(0, 128, 128); ">66</span> <span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 128, 128); ">67</span> <span style="color: rgb(0, 0, 0); ">}
</span><span style="color: rgb(0, 128, 128); ">68</span> </span></span></font></div><img src ="http://www.cppblog.com/Naeioi/aggbug/132866.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Naeioi/" target="_blank">Naeioi Zhu</a> 2010-11-07 16:36 <a href="http://www.cppblog.com/Naeioi/archive/2010/11/07/132866.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>