<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ebeworld's Weblog &#187; Algorithms</title>
	<atom:link href="http://ebeworld.wordpress.com/category/algorithms/feed/" rel="self" type="application/rss+xml" />
	<link>http://ebeworld.wordpress.com</link>
	<description>Trying to create</description>
	<lastBuildDate>Wed, 09 Dec 2009 19:33:44 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ebeworld.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/cbd4023a12f78275f1676e6f81eb8a20?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Ebeworld's Weblog &#187; Algorithms</title>
		<link>http://ebeworld.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ebeworld.wordpress.com/osd.xml" title="Ebeworld&#8217;s Weblog" />
		<item>
		<title>pku 3589</title>
		<link>http://ebeworld.wordpress.com/2008/10/14/pku-3589/</link>
		<comments>http://ebeworld.wordpress.com/2008/10/14/pku-3589/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 05:27:42 +0000</pubDate>
		<dc:creator>ebeworld</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[acm]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[pku]]></category>

		<guid isPermaLink="false">http://ebeworld.wordpress.com/?p=51</guid>
		<description><![CDATA[Number-guessing Game




Time Limit: 1000MS
 
Memory Limit: 65536K


Total Submissions: 1499
 
Accepted: 1106




Description


Larry likes playing the number-guessing game.
Two players are needed in a game. Suppose they are X and Y, and X presents a number for Y to guess. Firstly, X chooses a number with four different digits, keeping it in mind, and tells Y to start guessing. Every time Y has guessed, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ebeworld.wordpress.com&blog=5157598&post=51&subd=ebeworld&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div class="ptt" lang="en-US">Number-guessing Game</div>
<div class="plm">
<table border="0" align="center">
<tbody>
<tr>
<td><strong>Time Limit:</strong> 1000MS</td>
<td width="10px"> </td>
<td><strong>Memory Limit:</strong> 65536K</td>
</tr>
<tr>
<td><strong>Total Submissions:</strong> 1499</td>
<td width="10px"> </td>
<td><strong>Accepted:</strong> 1106</td>
</tr>
</tbody>
</table>
</div>
<p class="pst">Description</p>
<div class="ptx" lang="en-US">
<div>
<p>Larry likes playing the number-guessing game.</p>
<p>Two players are needed in a game. Suppose they are X and Y, and X presents a number for Y to guess. Firstly, X chooses a number with four different digits, keeping it in mind, and tells Y to start guessing. Every time Y has guessed, X should give out *A*B to show Y how close to the number his answer is. Here the symbol * stands for a number, and the number before A is the number of digits in Y&#8217;s answer with both correct value and position. The number before B is the number of digits in Y&#8217;s answer with correct value but incorrect position.</p>
<p>For example, if X chooses the number 5204, and Y guesses 4902, then X should give out 1A2B, in which 1A corresponds for digit 0 with both correct value and position and 2B corresponds for digit 2 and 4 with correct value but incorrect position. Then Y will go on guessing according to 1A2B that X presents him until he gets the totally correct number 5204 (when X shows him 4A0B).</p>
<p>Now you are given two numbers, and what you need to do is just testing how close they are.</p></div>
</div>
<p class="pst">Input</p>
<div class="ptx" lang="en-US">
<p>The first line of the input is an integer <em>T</em> which indicates the number of test cases. For each test case, input two numbers. Each number contains four different digits.</div>
<p class="pst">Output</p>
<div class="ptx" lang="en-US">
<p>For each test case, output *A*B stands for how close the two numbers are.<br />
　</p></div>
<p class="pst">Sample Input</p>
<pre class="sio">2
5204 4902
0123 3210</pre>
<p class="pst">Sample Output</p>
<pre class="sio">1A2B
0A4B</pre>
<p class="pst">Source</p>
<div class="ptx" lang="en-US"><a href="http://acm.pku.edu.cn/JudgeOnline/searchproblem?field=source&amp;key=South+Central+China+2008+hosted+by+NUDT">South Central China 2008 hosted by NUDT</a></div>
<div class="ptx" lang="en-US">
<div class="ptx" lang="en-US">#include&lt;iostream&gt;</div>
<div class="ptx" lang="en-US">using namespace std;</div>
<div class="ptx" lang="en-US">int main(){ </div>
<div class="ptx" lang="en-US">char a[5],b[5]; </div>
<div class="ptx" lang="en-US">int n,i,j; </div>
<div class="ptx" lang="en-US">cin&gt;&gt;n; </div>
<div class="ptx" lang="en-US">while(n) {</div>
<div class="ptx" lang="en-US">  cin&gt;&gt;a&gt;&gt;b;</div>
<div class="ptx" lang="en-US">  int x=0,y=0; </div>
<div class="ptx" lang="en-US">    for( i = 0; i&lt; 4; i++)</div>
<div class="ptx" lang="en-US">   for( j = 0 ; j &lt; 4; j++)   {</div>
<div class="ptx" lang="en-US">    if(a[i]==b[i])</div>
<div class="ptx" lang="en-US">     x++;</div>
<div class="ptx" lang="en-US">    if(i!=j)</div>
<div class="ptx" lang="en-US">     if(a[i]==b[j])     {</div>
<div class="ptx" lang="en-US">      y++;</div>
<div class="ptx" lang="en-US">     break;</div>
<div class="ptx" lang="en-US">     }</div>
<div class="ptx" lang="en-US">       } </div>
<div class="ptx" lang="en-US">cout&lt;&lt;x/4&lt;&lt;&#8221;A&#8221;&lt;&lt;y&lt;&lt;&#8221;B&#8221;&lt;&lt;endl;</div>
<div class="ptx" lang="en-US">  n&#8211;; </div>
<div class="ptx" lang="en-US">} </div>
<div class="ptx" lang="en-US">return 0;</div>
<div class="ptx" lang="en-US">}</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ebeworld.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ebeworld.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ebeworld.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ebeworld.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ebeworld.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ebeworld.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ebeworld.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ebeworld.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ebeworld.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ebeworld.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ebeworld.wordpress.com&blog=5157598&post=51&subd=ebeworld&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ebeworld.wordpress.com/2008/10/14/pku-3589/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e5ebaca1d1c2b06cc18b8d977bb1c37d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ebeworld</media:title>
		</media:content>
	</item>
	</channel>
</rss>