﻿<?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++博客---------OUTDOMEL---------随笔分类-OI之路</title><link>http://www.cppblog.com/liaorc/category/5604.html</link><description>从明天开始，放弃一切</description><language>zh-cn</language><lastBuildDate>Mon, 19 May 2008 21:38:56 GMT</lastBuildDate><pubDate>Mon, 19 May 2008 21:38:56 GMT</pubDate><ttl>60</ttl><item><title>USACO 1.1.4 Broken Necklace</title><link>http://www.cppblog.com/liaorc/archive/2008/04/12/46897.html</link><dc:creator>XWB-L</dc:creator><author>XWB-L</author><pubDate>Fri, 11 Apr 2008 22:47:00 GMT</pubDate><guid>http://www.cppblog.com/liaorc/archive/2008/04/12/46897.html</guid><wfw:comment>http://www.cppblog.com/liaorc/comments/46897.html</wfw:comment><comments>http://www.cppblog.com/liaorc/archive/2008/04/12/46897.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liaorc/comments/commentRss/46897.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liaorc/services/trackbacks/46897.html</trackback:ping><description><![CDATA[
		<p align="left">
				<b>
						<font face="Times New Roman" size="2">Broken Necklace</font>
				</b>
		</p>
		<p align="left">
				<b>
						<font size="2">破碎的项链</font>
				</b>
		</p>
		<p align="left">
				<font size="2">译 <font face="Times New Roman">by timgreen</font></font>
		</p>
		<p>
				<font size="2">你有一条由<font face="Times New Roman">N</font>个红色的，白色的，或蓝色的珠子组成的项链<font face="Times New Roman">(3&lt;=N&lt;=350)</font>，珠子是随意安排的。 这里是 <font face="Times New Roman">n=29 </font>的二个例子<font face="Times New Roman">:</font></font>
				<br />
		</p>
		<pre>
				<font size="2">
						<br />              1 2                               1 2
            r b b r                           b r r b
          r         b                       b         b
         r           r                     b           r
        r             r                   w             r
       b               r                 w               w
      b                 b               r                 r
      b                 b               b                 b
      b                 b               r                 b
       r               r                 b               r
        b             r                   r             r
         b           r                     r           r
           r       r                         r       b
             r b r                             r r w
              图片 A                          图片  B
                 
                  r 代表 红色的珠子      
                     b 代表 蓝色的珠子   
                     w 代表 白色的珠子
</font>
		</pre>
		<p>
				<font size="2">第一和第二个珠子在图片中已经被作记号。 </font>
		</p>
		<p>
				<font size="2">图片 <font face="Times New Roman">A </font>中的项链可以用下面的字符串表示： </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">brbrrrbbbrrrrrbrrbbrbbbbrrrrb . </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">假如你要在一些点打破项链,展开成一条直线，然后从一端开始收集同颜色的珠子直到你遇到一个不同的颜色珠子，在另一端做同样的事。(颜色可能与在这之前收集的不同) 确定应该在哪里打破项链来收集到最大多数的数目的子。 Example 举例来说，在图片 A 中的项链，可以收集到8个珠子,在珠子 9 和珠子 10 或珠子 24 和珠子 25 之间打断项链。 在一些项链中，包括白色的珠子如图片 B 所示。 当收集珠子的时候，一个被遇到的白色珠子可以被当做红色也可以被当做蓝色。 表现项链的字符串将会包括三符号 r ， b 和 w 。 写一个程序来确定从一条被供应的项链最大可以被收集珠子数目。 </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">
						<b>PROGRAM NAME: beads</b>
				</font>
		</p>
		<p>
				<font face="Times New Roman" size="2">
						<b>INPUT FORMAT </b>
				</font>
		</p>
		<table width="759" border="1">
				<tbody>
						<tr>
								<td width="87">
										<font face="Times New Roman" size="2">第 1 行: </font>
								</td>
								<td width="656">
										<font face="Times New Roman" size="2">N, 珠子的数目 </font>
								</td>
						</tr>
						<tr>
								<td width="87">
										<font face="Times New Roman" size="2">第 2 行: </font>
								</td>
								<td width="656">
										<font face="Times New Roman" size="2">一串度为N的字符串, 每个字符是 r ， b 或 w。 </font>
								</td>
						</tr>
				</tbody>
		</table>
		<p>
				<font face="Times New Roman" size="2">
						<b>SAMPLE INPUT (file beads.in) </b>
				</font>
		</p>
		<p>
				<font face="Times New Roman" size="2">29 </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">wwwbbrwrbrbrrbrbrwrwwrbwrwrrb </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">
						<b>OUTPUT FORMAT </b>
				</font>
		</p>
		<p>
				<font face="Times New Roman" size="2">单独的一行包含从被供应的项链可以被收集的珠子数目的最大值。 </font>
		</p>
		<p>
				<font face="Times New Roman" size="2">
						<b>SAMPLE OUTPUT (file beads.out) </b>
				</font>
		</p>
		<p>
				<font face="Times New Roman" size="2">11 <br /><br /><hr /><br /><font size="3">由于整个珠子连起来是一个项链，也就是一个环。我在读入数据以后在一个数组里吧整个项链连续存了3遍。然后我从中间的一组数据中枚举断开点，向两边扩展。剩下的算就行了<br /><p></p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdlib.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> N 350*3+30</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> s[N];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> input()<br /><img id="Codehighlighter1_90_220_Open_Image" onclick="this.style.display='none'; Codehighlighter1_90_220_Open_Text.style.display='none'; Codehighlighter1_90_220_Closed_Image.style.display='inline'; Codehighlighter1_90_220_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_90_220_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_90_220_Closed_Text.style.display='none'; Codehighlighter1_90_220_Open_Image.style.display='inline'; Codehighlighter1_90_220_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_90_220_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_90_220_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    getchar();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,s);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_182_218_Open_Image" onclick="this.style.display='none'; Codehighlighter1_182_218_Open_Text.style.display='none'; Codehighlighter1_182_218_Closed_Image.style.display='inline'; Codehighlighter1_182_218_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_182_218_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_182_218_Closed_Text.style.display='none'; Codehighlighter1_182_218_Open_Image.style.display='inline'; Codehighlighter1_182_218_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_182_218_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_182_218_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        s[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">n]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">n]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> getbeans(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> l,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r)<br /><img id="Codehighlighter1_249_707_Open_Image" onclick="this.style.display='none'; Codehighlighter1_249_707_Open_Text.style.display='none'; Codehighlighter1_249_707_Closed_Image.style.display='inline'; Codehighlighter1_249_707_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_249_707_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_249_707_Closed_Text.style.display='none'; Codehighlighter1_249_707_Open_Image.style.display='inline'; Codehighlighter1_249_707_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_249_707_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_249_707_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">l,j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">r;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> f1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,f2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">&gt;=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_307_460_Open_Image" onclick="this.style.display='none'; Codehighlighter1_307_460_Open_Text.style.display='none'; Codehighlighter1_307_460_Closed_Image.style.display='inline'; Codehighlighter1_307_460_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_307_460_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_307_460_Closed_Text.style.display='none'; Codehighlighter1_307_460_Open_Image.style.display='inline'; Codehighlighter1_307_460_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_307_460_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_307_460_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">s[l]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            l</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s[i]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">s[l]</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">s[i]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            f1</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">n</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_486_639_Open_Image" onclick="this.style.display='none'; Codehighlighter1_486_639_Open_Text.style.display='none'; Codehighlighter1_486_639_Closed_Image.style.display='inline'; Codehighlighter1_486_639_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_486_639_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_486_639_Closed_Text.style.display='none'; Codehighlighter1_486_639_Open_Image.style.display='inline'; Codehighlighter1_486_639_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_486_639_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_486_639_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s[r]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">s[j]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s[j]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">s[r]</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">s[j]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            f2</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(f1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">f2</span><span style="COLOR: #000000">&gt;=</span><span style="COLOR: #000000">n)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> f1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">f2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> work()<br /><img id="Codehighlighter1_721_985_Open_Image" onclick="this.style.display='none'; Codehighlighter1_721_985_Open_Text.style.display='none'; Codehighlighter1_721_985_Closed_Image.style.display='inline'; Codehighlighter1_721_985_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_721_985_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_721_985_Closed_Text.style.display='none'; Codehighlighter1_721_985_Open_Image.style.display='inline'; Codehighlighter1_721_985_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_721_985_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_721_985_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> got</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> ans</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_793_924_Open_Image" onclick="this.style.display='none'; Codehighlighter1_793_924_Open_Text.style.display='none'; Codehighlighter1_793_924_Closed_Image.style.display='inline'; Codehighlighter1_793_924_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_793_924_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_793_924_Closed_Text.style.display='none'; Codehighlighter1_793_924_Open_Image.style.display='inline'; Codehighlighter1_793_924_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_793_924_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_793_924_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">s[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">])<br /><img id="Codehighlighter1_828_918_Open_Image" onclick="this.style.display='none'; Codehighlighter1_828_918_Open_Text.style.display='none'; Codehighlighter1_828_918_Closed_Image.style.display='inline'; Codehighlighter1_828_918_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_828_918_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_828_918_Closed_Text.style.display='none'; Codehighlighter1_828_918_Open_Image.style.display='inline'; Codehighlighter1_828_918_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span id="Codehighlighter1_828_918_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_828_918_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            got</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            t</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getbeans(i,i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            ans</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ans</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">t</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">ans:t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(got)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> ans;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br /><img id="Codehighlighter1_999_1127_Open_Image" onclick="this.style.display='none'; Codehighlighter1_999_1127_Open_Text.style.display='none'; Codehighlighter1_999_1127_Closed_Image.style.display='inline'; Codehighlighter1_999_1127_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_999_1127_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_999_1127_Closed_Text.style.display='none'; Codehighlighter1_999_1127_Open_Image.style.display='inline'; Codehighlighter1_999_1127_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_999_1127_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_999_1127_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">beads.in</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">r</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdin);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">beads.out</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdout);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    input();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,work());<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    exit(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div></font></font>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
		</p>
<img src ="http://www.cppblog.com/liaorc/aggbug/46897.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liaorc/" target="_blank">XWB-L</a> 2008-04-12 06:47 <a href="http://www.cppblog.com/liaorc/archive/2008/04/12/46897.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>USACO 1.1.3 Friday the Thirteenth</title><link>http://www.cppblog.com/liaorc/archive/2008/04/12/46896.html</link><dc:creator>XWB-L</dc:creator><author>XWB-L</author><pubDate>Fri, 11 Apr 2008 22:42:00 GMT</pubDate><guid>http://www.cppblog.com/liaorc/archive/2008/04/12/46896.html</guid><wfw:comment>http://www.cppblog.com/liaorc/comments/46896.html</wfw:comment><comments>http://www.cppblog.com/liaorc/archive/2008/04/12/46896.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liaorc/comments/commentRss/46896.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liaorc/services/trackbacks/46896.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">黑色星期五</font>
		</p>
		<p>
				<br />
				<font size="2">译 by 孖哥</font>
		</p>
		<p>
				<font size="2">13号又是星期五是一个不寻常的日子吗?</font>
		</p>
		<p>
				<font size="2">
				</font> </p>
		<p>
				<font size="2">13号在星期五比在其他日少吗?为了回答这个问题,写一个程序来计算在n年里13<br />日落在星期一,星期二......星期日的次数.这个测试从1900年1月1日到<br />1900+n-1年12月31日.n是一个非负数且不大于400.</font>
		</p>
		<p>
				<font size="2">这里有一些你要知道的:</font>
		</p>
		<p>
				<font size="2">1900年1月1日是星期一.<br />4,6,11和9月有30天.其他月份除了2月有31天.闰年2月有29天,平年2月有28天.<br />年份可以被4整除的为闰年(1992=4*498 所以 1992年是闰年,但是1990年不是闰年)<br />以上规则不适合于世纪年.可以被400整除的世纪年为闰年,否则为平年.所以,1700,1800,1900和2100年是平年,而2000年是闰年.</font>
		</p>
		<p>
				<font size="2">请不要预先算好数据! </font>
		</p>
		<p>
				<font size="2">PROGRAM NAME: friday</font>
		</p>
		<p>
				<font size="2">INPUT FORMAT</font>
		</p>
		<p>
				<font size="2">一个整数n.</font>
		</p>
		<p>
				<font size="2">SAMPLE INPUT (file friday.in) </font>
		</p>
		<p>
				<font size="2">20</font>
		</p>
		<p>
				<font size="2">OUTPUT FORMAT</font>
		</p>
		<p>
				<font size="2">七个在一行且相分开的整数,它们代表13日是星期六,星期日,星期一.....星期五的次数.</font>
		</p>
		<p>
				<font size="2">SAMPLE OUTPUT (file friday.out)</font>
		</p>
		<p>
				<font size="2">36 33 34 33 35 35 34<br /><br /><hr /><br />总的来说，由于总共N才是400年，我就是一天一天直接枚举的，都算出来了<br /></font>
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">stdlib.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">stdio.h</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
						<img id="Codehighlighter1_51_89_Open_Image" onclick="this.style.display='none'; Codehighlighter1_51_89_Open_Text.style.display='none'; Codehighlighter1_51_89_Closed_Image.style.display='inline'; Codehighlighter1_51_89_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_51_89_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_51_89_Closed_Text.style.display='none'; Codehighlighter1_51_89_Open_Image.style.display='inline'; Codehighlighter1_51_89_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> mon[</span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">=</span>
				<span id="Codehighlighter1_51_89_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_51_89_Open_Text">
						<span style="COLOR: #000000">{</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">28</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">30</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">30</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">30</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">30</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">}</span>
				</span>
				<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_103_105_Open_Image" onclick="this.style.display='none'; Codehighlighter1_103_105_Open_Text.style.display='none'; Codehighlighter1_103_105_Closed_Image.style.display='inline'; Codehighlighter1_103_105_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_103_105_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_103_105_Closed_Text.style.display='none'; Codehighlighter1_103_105_Open_Image.style.display='inline'; Codehighlighter1_103_105_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> ans[</span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">=</span>
				<span id="Codehighlighter1_103_105_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_103_105_Open_Text">
						<span style="COLOR: #000000">{</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">}</span>
				</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n,end;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> work()<br /><img id="Codehighlighter1_132_749_Open_Image" onclick="this.style.display='none'; Codehighlighter1_132_749_Open_Text.style.display='none'; Codehighlighter1_132_749_Closed_Image.style.display='inline'; Codehighlighter1_132_749_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_132_749_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_132_749_Closed_Text.style.display='none'; Codehighlighter1_132_749_Open_Image.style.display='inline'; Codehighlighter1_132_749_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_132_749_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_132_749_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> y,m,d;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> w</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    y</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1900</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    end</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">y</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">n</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    m</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">d</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000">(y</span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000">end</span>
						<span style="COLOR: #000000">||</span>
						<span style="COLOR: #000000">m</span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000">12</span>
						<span style="COLOR: #000000">||</span>
						<span style="COLOR: #000000">d</span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_247_631_Open_Image" onclick="this.style.display='none'; Codehighlighter1_247_631_Open_Text.style.display='none'; Codehighlighter1_247_631_Closed_Image.style.display='inline'; Codehighlighter1_247_631_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_247_631_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_247_631_Closed_Text.style.display='none'; Codehighlighter1_247_631_Open_Image.style.display='inline'; Codehighlighter1_247_631_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_247_631_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_247_631_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(d</span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000">mon[m]</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_281_325_Open_Image" onclick="this.style.display='none'; Codehighlighter1_281_325_Open_Text.style.display='none'; Codehighlighter1_281_325_Closed_Image.style.display='inline'; Codehighlighter1_281_325_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_281_325_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_281_325_Closed_Text.style.display='none'; Codehighlighter1_281_325_Open_Image.style.display='inline'; Codehighlighter1_281_325_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_281_325_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_281_325_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            d</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            m</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(m</span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000">13</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_353_538_Open_Image" onclick="this.style.display='none'; Codehighlighter1_353_538_Open_Text.style.display='none'; Codehighlighter1_353_538_Closed_Image.style.display='inline'; Codehighlighter1_353_538_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_353_538_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_353_538_Closed_Text.style.display='none'; Codehighlighter1_353_538_Open_Image.style.display='inline'; Codehighlighter1_353_538_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_353_538_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_353_538_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            y</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            m</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">((y</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">100</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">y</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">4</span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">)</span>
										<span style="COLOR: #000000">||</span>
										<span style="COLOR: #000000">y</span>
										<span style="COLOR: #000000">%</span>
										<span style="COLOR: #000000">400</span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_443_484_Open_Image" onclick="this.style.display='none'; Codehighlighter1_443_484_Open_Text.style.display='none'; Codehighlighter1_443_484_Closed_Image.style.display='inline'; Codehighlighter1_443_484_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_443_484_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_443_484_Closed_Text.style.display='none'; Codehighlighter1_443_484_Open_Image.style.display='inline'; Codehighlighter1_443_484_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_443_484_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
												<img src="http://www.cppblog.com/images/dot.gif" />
										</span>
										<span id="Codehighlighter1_443_484_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                mon[</span>
												<span style="COLOR: #000000">2</span>
												<span style="COLOR: #000000">]</span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000">29</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">else</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                mon[</span>
										<span style="COLOR: #000000">2</span>
										<span style="COLOR: #000000">]</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">28</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(d</span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000">13</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            ans[w]</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        w</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        w</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">(w</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)</span>
								<span style="COLOR: #000000">%</span>
								<span style="COLOR: #000000">7</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        d</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d %d </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,ans[</span>
						<span style="COLOR: #000000">6</span>
						<span style="COLOR: #000000">],ans[</span>
						<span style="COLOR: #000000">7</span>
						<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000">(i</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">4</span>
						<span style="COLOR: #000000">;i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d </span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,ans[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,ans[</span>
						<span style="COLOR: #000000">5</span>
						<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> main()<br /><img id="Codehighlighter1_763_884_Open_Image" onclick="this.style.display='none'; Codehighlighter1_763_884_Open_Text.style.display='none'; Codehighlighter1_763_884_Closed_Image.style.display='inline'; Codehighlighter1_763_884_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_763_884_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_763_884_Closed_Text.style.display='none'; Codehighlighter1_763_884_Open_Image.style.display='inline'; Codehighlighter1_763_884_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_763_884_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_763_884_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">friday.in</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">r</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,stdin);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">friday.out</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">w</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,stdout);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,</span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    work();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    exit(</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/liaorc/aggbug/46896.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liaorc/" target="_blank">XWB-L</a> 2008-04-12 06:42 <a href="http://www.cppblog.com/liaorc/archive/2008/04/12/46896.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>USACO 1.1.2 Greedy Gift Givers</title><link>http://www.cppblog.com/liaorc/archive/2008/04/12/46895.html</link><dc:creator>XWB-L</dc:creator><author>XWB-L</author><pubDate>Fri, 11 Apr 2008 22:38:00 GMT</pubDate><guid>http://www.cppblog.com/liaorc/archive/2008/04/12/46895.html</guid><wfw:comment>http://www.cppblog.com/liaorc/comments/46895.html</wfw:comment><comments>http://www.cppblog.com/liaorc/archive/2008/04/12/46895.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liaorc/comments/commentRss/46895.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liaorc/services/trackbacks/46895.html</trackback:ping><description><![CDATA[
		<font size="2">Greedy Gift Givers<br /><br />贪婪的礼物送礼者<br /><br />译 by tim green<br /><br />对于一群要互送礼物的朋友，你要确定每个人送出的礼物比收到的多多少(and vice versa for those who view gift giving with cynicism)。<br />在这一个问题中，每个人都准备了一些钱来送礼物，而这些钱将会被平均分给那些将收到他的礼物的人。<br />然而，在任何一群朋友中，有些人将送出较多的礼物(可能是因为有较多的朋友)，有些人有准备了较多的钱。<br />给出一群朋友， 没有人的名字会长于 14 字符，给出每个人将花在送礼上的钱，和将收到他的礼物的人的列表，<br />请确定每个人收到的比送出的钱多的数目。<br /><br />IMPORTANT NOTE<br /><br />测试系统是 Linux 符合标准的 Unix 的协定。<br />用'\n'作为行的<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%BD%E1%CA%F8">结束</span>。<br />这和　Windows 系统用'\n' 和 '\r'作为行的结束是不同的。<br />你的<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%B3%CC%D0%F2">程序</span>不要被这困住了。<br /><br />PROGRAM NAME: gift1<br /><br />INPUT FORMAT第 1 行: 人数NP,2&lt;= NP&lt;=10  <br /><br />第 2到 NP+1 行: <br />这NP个在组里人的名字　一个名字一行<br /><br />第NP＋2到最后：<br />这里的NP段内容是这样组织的：<br />第一行是将会送出礼物人的名字。<br />第二行包含二个数字:　第一个是原有的钱的数目（在0到2000的范围里），第二个NGi是将收到这个送礼者礼物的人的个数 如果 NGi 是非零的, 在下面 NGi 行列出礼物的接受者的名字，一个名字一行。<br /><br /><br /><br />SAMPLE INPUT (file gift1.in) <br /><br />5<br />dave<br />laura<br />owen<br />vick<br />amr<br />dave<br />200 3<br />laura<br />owen<br />vick<br />owen<br />500 1<br />dave<br />amr<br />150 2<br />vick<br />owen<br />laura<br />0 2<br />amr<br />vick<br />vick<br />0 0<br /><br />OUTPUT FORMAT<br /><br />输出 NP 行<br />每行是一个的名字加上空格再加上收到的比送出的钱多的数目。<br />对于每一个人，他名字的打印顺序应和他在输入的2到NP＋1行中输入的顺序相同。所有的送礼的钱都是整数。<br />每个人把相同数目的钱给每位要送礼的朋友，而且尽可能多给，不能给出的钱被送礼者自己保留。<br /><br />SAMPLE OUTPUT (file gift1.out)<br /><br />dave 302<br />laura 66<br />owen -359<br />vick 141<br />amr -150<br /><br /><hr /><br />这个题也很简单，主要就是说把每个人的钱给其他人分一下就行了。<br />唯一麻烦一点的就是对人名的处理，我是直接比较的，没什么好方法。再有一个就是注意一个人有的钱数不能整除他分钱给的人数的时候要把余数留下。<br />最后用每个人得到的钱减了给的就行了<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdlib.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> S 20</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> peo<br /><img id="Codehighlighter1_63_121_Open_Image" onclick="this.style.display='none'; Codehighlighter1_63_121_Open_Text.style.display='none'; Codehighlighter1_63_121_Closed_Image.style.display='inline'; Codehighlighter1_63_121_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_63_121_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_63_121_Closed_Text.style.display='none'; Codehighlighter1_63_121_Open_Image.style.display='inline'; Codehighlighter1_63_121_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_63_121_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_63_121_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> name[S];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> have;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000">p[</span><span style="COLOR: #000000">11</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> scmp(</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">s1,</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">s2)<br /><img id="Codehighlighter1_165_339_Open_Image" onclick="this.style.display='none'; Codehighlighter1_165_339_Open_Text.style.display='none'; Codehighlighter1_165_339_Closed_Image.style.display='inline'; Codehighlighter1_165_339_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_165_339_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_165_339_Closed_Text.style.display='none'; Codehighlighter1_165_339_Open_Image.style.display='inline'; Codehighlighter1_165_339_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_165_339_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_165_339_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(strlen(s1)</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">strlen(s2))<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(s1[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_257_323_Open_Image" onclick="this.style.display='none'; Codehighlighter1_257_323_Open_Text.style.display='none'; Codehighlighter1_257_323_Closed_Image.style.display='inline'; Codehighlighter1_257_323_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_257_323_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_257_323_Closed_Text.style.display='none'; Codehighlighter1_257_323_Open_Image.style.display='inline'; Codehighlighter1_257_323_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_257_323_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_257_323_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(s1[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">s2[i])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> getname(</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">s)<br /><img id="Codehighlighter1_363_461_Open_Image" onclick="this.style.display='none'; Codehighlighter1_363_461_Open_Text.style.display='none'; Codehighlighter1_363_461_Closed_Image.style.display='inline'; Codehighlighter1_363_461_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_363_461_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_363_461_Closed_Text.style.display='none'; Codehighlighter1_363_461_Open_Image.style.display='inline'; Codehighlighter1_363_461_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_363_461_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_363_461_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_401_459_Open_Image" onclick="this.style.display='none'; Codehighlighter1_401_459_Open_Text.style.display='none'; Codehighlighter1_401_459_Closed_Image.style.display='inline'; Codehighlighter1_401_459_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_401_459_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_401_459_Closed_Text.style.display='none'; Codehighlighter1_401_459_Open_Image.style.display='inline'; Codehighlighter1_401_459_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_401_459_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_401_459_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(scmp(s,p[i].name))<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> input()<br /><img id="Codehighlighter1_477_630_Open_Image" onclick="this.style.display='none'; Codehighlighter1_477_630_Open_Text.style.display='none'; Codehighlighter1_477_630_Closed_Image.style.display='inline'; Codehighlighter1_477_630_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_477_630_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_477_630_Closed_Text.style.display='none'; Codehighlighter1_477_630_Open_Image.style.display='inline'; Codehighlighter1_477_630_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_477_630_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_477_630_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,j,t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> now;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_552_628_Open_Image" onclick="this.style.display='none'; Codehighlighter1_552_628_Open_Text.style.display='none'; Codehighlighter1_552_628_Closed_Image.style.display='inline'; Codehighlighter1_552_628_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_552_628_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_552_628_Closed_Text.style.display='none'; Codehighlighter1_552_628_Open_Image.style.display='inline'; Codehighlighter1_552_628_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_552_628_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_552_628_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p[i].name);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        getchar();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        p[i].</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> work()<br /><img id="Codehighlighter1_645_1111_Open_Image" onclick="this.style.display='none'; Codehighlighter1_645_1111_Open_Text.style.display='none'; Codehighlighter1_645_1111_Closed_Image.style.display='inline'; Codehighlighter1_645_1111_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_645_1111_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_645_1111_Closed_Text.style.display='none'; Codehighlighter1_645_1111_Open_Image.style.display='inline'; Codehighlighter1_645_1111_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_645_1111_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_645_1111_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,j,t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> str[S];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> now,tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(t</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;t</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n;t</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_721_1109_Open_Image" onclick="this.style.display='none'; Codehighlighter1_721_1109_Open_Text.style.display='none'; Codehighlighter1_721_1109_Closed_Image.style.display='inline'; Codehighlighter1_721_1109_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_721_1109_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_721_1109_Closed_Text.style.display='none'; Codehighlighter1_721_1109_Open_Image.style.display='inline'; Codehighlighter1_721_1109_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_721_1109_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_721_1109_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        getchar();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        now</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getname(str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">p[now].have,</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">p[now].m);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        getchar();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">p[now].m;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_898_1036_Open_Image" onclick="this.style.display='none'; Codehighlighter1_898_1036_Open_Text.style.display='none'; Codehighlighter1_898_1036_Closed_Image.style.display='inline'; Codehighlighter1_898_1036_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_898_1036_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_898_1036_Closed_Text.style.display='none'; Codehighlighter1_898_1036_Open_Image.style.display='inline'; Codehighlighter1_898_1036_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span id="Codehighlighter1_898_1036_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_898_1036_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            getchar();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            tmp</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">getname(str);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            p[tmp].</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">p[now].have</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">p[now].m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(p[now].m)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            p[now].</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">p[now].have</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">p[now].m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> output()<br /><img id="Codehighlighter1_1128_1231_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1128_1231_Open_Text.style.display='none'; Codehighlighter1_1128_1231_Closed_Image.style.display='inline'; Codehighlighter1_1128_1231_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1128_1231_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1128_1231_Closed_Text.style.display='none'; Codehighlighter1_1128_1231_Open_Image.style.display='inline'; Codehighlighter1_1128_1231_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_1128_1231_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_1128_1231_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1166_1229_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1166_1229_Open_Text.style.display='none'; Codehighlighter1_1166_1229_Closed_Image.style.display='inline'; Codehighlighter1_1166_1229_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1166_1229_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1166_1229_Closed_Text.style.display='none'; Codehighlighter1_1166_1229_Open_Image.style.display='inline'; Codehighlighter1_1166_1229_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_1166_1229_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_1166_1229_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s %d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p[i].name,p[i].</span><span style="COLOR: #0000ff">get</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">p[i].have);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br /><img id="Codehighlighter1_1245_1371_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1245_1371_Open_Text.style.display='none'; Codehighlighter1_1245_1371_Closed_Image.style.display='inline'; Codehighlighter1_1245_1371_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1245_1371_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1245_1371_Closed_Text.style.display='none'; Codehighlighter1_1245_1371_Open_Image.style.display='inline'; Codehighlighter1_1245_1371_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_1245_1371_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_1245_1371_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">gift1.in</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">r</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdin);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">gift1.out</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdout);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    input();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    work();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    output();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    exit(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div></font>
<img src ="http://www.cppblog.com/liaorc/aggbug/46895.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liaorc/" target="_blank">XWB-L</a> 2008-04-12 06:38 <a href="http://www.cppblog.com/liaorc/archive/2008/04/12/46895.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>USACO 1.1.1 Your Ride Is Here</title><link>http://www.cppblog.com/liaorc/archive/2008/04/12/46894.html</link><dc:creator>XWB-L</dc:creator><author>XWB-L</author><pubDate>Fri, 11 Apr 2008 22:31:00 GMT</pubDate><guid>http://www.cppblog.com/liaorc/archive/2008/04/12/46894.html</guid><wfw:comment>http://www.cppblog.com/liaorc/comments/46894.html</wfw:comment><comments>http://www.cppblog.com/liaorc/archive/2008/04/12/46894.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liaorc/comments/commentRss/46894.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liaorc/services/trackbacks/46894.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">Your Ride Is Here <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">你要乘坐的飞碟在这里</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">译</span>
						<span lang="EN-US">by tim green<o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个众所周知的事实，在每一慧星后面是一个不明飞行物</span>
						<span lang="EN-US">UFO</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这些不明飞行物时常来收集来自在地球上忠诚的支持者。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不幸地，他们的空间在每次旅行只能带上一群支持者。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">他们要做的是用一种聪明的方案让每一个团体人被慧星带走。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">他们为每个慧星起了一个名字，通过这些名字来决定一个团体是不是特定的慧星带走。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那个相配方案的细节在下面被给出；</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">你的工作要写一个程序来通过团体的名字和彗星的名字来决定一个组是否应该与在那一颗慧星后面的不明飞行物搭配。</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">团体的名字和慧星的名字都以下列各项方式转换成一个数字</span>
						<span lang="EN-US">: </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这个最后的数字代表名字中所有字母的信息，</span>
						<span lang="EN-US">"A" </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</span>
						<span lang="EN-US">1 </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span>
						<span lang="EN-US">"Z" </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</span>
						<span lang="EN-US">26</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">举例来说，团体</span>
						<span lang="EN-US">"USACO" </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会是</span>
						<span lang="EN-US">21*19*1*3*15=17955 </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果团体的数字</span>
						<span lang="EN-US">mod 47 </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等于慧星的数字</span>
						<span lang="EN-US">mod 47,</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么你要告诉这个团体准备好被带走</span>
						<span lang="EN-US">!<o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写一个程序读入慧星的名字和团体的名字，如果搭配打印</span>
						<span lang="EN-US">"GO"</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">否者打印</span>
						<span lang="EN-US">"STAY" <o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">团体的名字和慧星的名字将会是没有空格或标点的一串大写字母（不超过</span>
						<span lang="EN-US">6</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字母），</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">Examples: <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">Input<span style="mso-spacerun: yes">  </span>Output<span style="mso-spacerun: yes">  </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">COMETQ<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">HVNGAT<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">GO<span style="mso-spacerun: yes">  </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">ABSTAR<o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">USACO <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">STAY<span style="mso-spacerun: yes">  </span><o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span lang="EN-US">PROGRAM NAME</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						<span lang="EN-US">ride <o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">INPUT FORMAT <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</span>
						<span lang="EN-US">1 </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行</span>
						<span lang="EN-US">:<o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">彗星的名字（一个长度为</span>
						<span lang="EN-US">1</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">到</span>
						<span lang="EN-US">6</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的字符串）</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</span>
						<span lang="EN-US">2 </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">行</span>
						<span lang="EN-US">:<span style="mso-spacerun: yes">  </span><o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">团体的名字（一个长度为</span>
						<span lang="EN-US">1</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">到</span>
						<span lang="EN-US">6</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的字符串）</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span lang="EN-US">SAMPLE INPUT </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span>
						<span lang="EN-US">file ride.in</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">COMETQ <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">HVNGAT <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">OUTPUT FORMAT <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">单独一行包含</span>
						<span lang="EN-US">"STAR"</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或</span>
						<span lang="EN-US">"GO". <o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">SAMPLE OUTPUT (file ride.out) <o:p></o:p></font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p>
								<font size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">GO</font>
				</span>
		</p>
		<p>
		</p>
		<hr />
		<br />这个题，是在没什么好说的，就是USACO旅程的开始吧，谁知道啊<br />直接做，附个代码 
<p></p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdlib.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,b</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> input()<br /><img id="Codehighlighter1_102_383_Open_Image" onclick="this.style.display='none'; Codehighlighter1_102_383_Open_Text.style.display='none'; Codehighlighter1_102_383_Closed_Image.style.display='inline'; Codehighlighter1_102_383_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_102_383_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_102_383_Closed_Text.style.display='none'; Codehighlighter1_102_383_Open_Image.style.display='inline'; Codehighlighter1_102_383_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_102_383_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_102_383_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> s1[</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> s2[</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,s1);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(s1[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">s1[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_218_263_Open_Image" onclick="this.style.display='none'; Codehighlighter1_218_263_Open_Text.style.display='none'; Codehighlighter1_218_263_Closed_Image.style.display='inline'; Codehighlighter1_218_263_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_218_263_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_218_263_Closed_Text.style.display='none'; Codehighlighter1_218_263_Open_Image.style.display='inline'; Codehighlighter1_218_263_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_218_263_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_218_263_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        a</span><span style="COLOR: #000000">*=</span><span style="COLOR: #000000">(s1[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,s2);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(s2[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">s2[i]</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_336_381_Open_Image" onclick="this.style.display='none'; Codehighlighter1_336_381_Open_Text.style.display='none'; Codehighlighter1_336_381_Closed_Image.style.display='inline'; Codehighlighter1_336_381_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_336_381_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_336_381_Closed_Text.style.display='none'; Codehighlighter1_336_381_Open_Image.style.display='inline'; Codehighlighter1_336_381_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_336_381_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_336_381_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        b</span><span style="COLOR: #000000">*=</span><span style="COLOR: #000000">(s2[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> work()<br /><img id="Codehighlighter1_398_480_Open_Image" onclick="this.style.display='none'; Codehighlighter1_398_480_Open_Text.style.display='none'; Codehighlighter1_398_480_Closed_Image.style.display='inline'; Codehighlighter1_398_480_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_398_480_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_398_480_Closed_Text.style.display='none'; Codehighlighter1_398_480_Open_Image.style.display='inline'; Codehighlighter1_398_480_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_398_480_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_398_480_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(a</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">47</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">b</span><span style="COLOR: #000000">%</span><span style="COLOR: #000000">47</span><span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">GO\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">STAY\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br /><img id="Codehighlighter1_494_604_Open_Image" onclick="this.style.display='none'; Codehighlighter1_494_604_Open_Text.style.display='none'; Codehighlighter1_494_604_Closed_Image.style.display='inline'; Codehighlighter1_494_604_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_494_604_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_494_604_Closed_Text.style.display='none'; Codehighlighter1_494_604_Open_Image.style.display='inline'; Codehighlighter1_494_604_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_494_604_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_494_604_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ride.in</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">r</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdin);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    freopen(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ride.out</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">w</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,stdout);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    input();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    work();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    exit(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><img src ="http://www.cppblog.com/liaorc/aggbug/46894.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liaorc/" target="_blank">XWB-L</a> 2008-04-12 06:31 <a href="http://www.cppblog.com/liaorc/archive/2008/04/12/46894.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>11.04 第二次模拟测试 解题报告</title><link>http://www.cppblog.com/liaorc/archive/2007/11/06/35987.html</link><dc:creator>XWB-L</dc:creator><author>XWB-L</author><pubDate>Tue, 06 Nov 2007 14:43:00 GMT</pubDate><guid>http://www.cppblog.com/liaorc/archive/2007/11/06/35987.html</guid><wfw:comment>http://www.cppblog.com/liaorc/comments/35987.html</wfw:comment><comments>http://www.cppblog.com/liaorc/archive/2007/11/06/35987.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liaorc/comments/commentRss/35987.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liaorc/services/trackbacks/35987.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 这是第二次模拟测试的解题报告本次题目出自OIBH模拟赛题目如下：===================================================================================================================饮食问题（eatpuz.pas/c/cpp/in/out）时限:1 sec | 内存: 64 MB		...&nbsp;&nbsp;<a href='http://www.cppblog.com/liaorc/archive/2007/11/06/35987.html'>阅读全文</a><img src ="http://www.cppblog.com/liaorc/aggbug/35987.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liaorc/" target="_blank">XWB-L</a> 2007-11-06 22:43 <a href="http://www.cppblog.com/liaorc/archive/2007/11/06/35987.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>