﻿<?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++博客-LeafCore's Apple Orchard-文章分类-回到最初的地方</title><link>http://www.cppblog.com/LeafCore/category/17054.html</link><description>The busy bee has no time for sorrow.</description><language>zh-cn</language><lastBuildDate>Fri, 24 Jun 2011 23:55:30 GMT</lastBuildDate><pubDate>Fri, 24 Jun 2011 23:55:30 GMT</pubDate><ttl>60</ttl><item><title>递归——让思维更自然</title><link>http://www.cppblog.com/LeafCore/articles/149375.html</link><dc:creator>LeafCore</dc:creator><author>LeafCore</author><pubDate>Fri, 24 Jun 2011 04:25:00 GMT</pubDate><guid>http://www.cppblog.com/LeafCore/articles/149375.html</guid><wfw:comment>http://www.cppblog.com/LeafCore/comments/149375.html</wfw:comment><comments>http://www.cppblog.com/LeafCore/articles/149375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/LeafCore/comments/commentRss/149375.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/LeafCore/services/trackbacks/149375.html</trackback:ping><description><![CDATA[<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">递归&#8212;&#8212;让思维更自然<br /><br /></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环着色</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">n</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个方格摆成一个环，使用红、粉、绿三种颜色着色，相邻方格颜色不同，求可能的着色数。</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用三种颜色着色</span><span lang="EN-US" style="color: green"><font face="Times New Roman">n</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个方格的环等价于先使用三种颜色着色</span><span lang="EN-US" style="color: green"><font face="Times New Roman">n-1</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个方格的环，着色最后一个方格时，有两种可能情形，左边和右边方格颜色不同，此时可以着上一种颜色，左边和右边方格颜色相同，可以着上两种颜色。</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">color(n)=color(n-1)+color(n-2)*2<br /><br /></font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字符串</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个长为</span><span lang="EN-US" style="color: green"><font face="Times New Roman">n</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的字符串，可以含有字符</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">b</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">d</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">只可以出现偶数次，</span><span lang="EN-US" style="color: green"><font face="Times New Roman">b</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">d</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以随意出现。求可能的字符串数。</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一个长度为</span><span lang="EN-US" style="color: green"><font face="Times New Roman">n</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的字符串可以分成：</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">奇</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">奇、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">偶</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">奇、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">奇</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">偶、</span><span lang="EN-US" style="color: green"><font face="Times New Roman">a</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">偶</span><span lang="EN-US" style="color: green"><font face="Times New Roman">c</font></span><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">偶。</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(1)=0<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aeco(1)=1<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoce(1)=1<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aece(1)=2<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(n)=2*aoco(n-1)+aeco(n-1)+aoce(n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aeco(n)=2*aeco(n-1)+aoco(n-1)+aece(n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoce(n)=2*aoce(n-1)+aece(n-1)+aoco(n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aece(n)=2*aece(n-1)+aoce(n-1)+aeco(n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">递归式的一些性质</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(n)+aeco(n)+aoce(n)+aece(n)=2^(2n)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(n)+aece(n)=2^(2n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(n)=aoco(n-1)+2^(2n-2)-aece(n-1)=2*aoco(n-1)+2^(2n-3)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco(n)/2^(n)=aoco(n-1)/2^(n-1)+2^(n-3)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span style="color: green; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通项公式</span><span lang="EN-US" style="color: green"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoco=2^(2n-2)-2^(n-1)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aeco=2^(2n-2)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aoce=2^(2n-2)<o:p></o:p></font></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="color: green"><font face="Times New Roman">aece=2^(2n-2)+2^(n-1)<o:p></o:p></font></span></p><img src ="http://www.cppblog.com/LeafCore/aggbug/149375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/LeafCore/" target="_blank">LeafCore</a> 2011-06-24 12:25 <a href="http://www.cppblog.com/LeafCore/articles/149375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个简单的虚拟机</title><link>http://www.cppblog.com/LeafCore/articles/148292.html</link><dc:creator>LeafCore</dc:creator><author>LeafCore</author><pubDate>Wed, 08 Jun 2011 11:17:00 GMT</pubDate><guid>http://www.cppblog.com/LeafCore/articles/148292.html</guid><wfw:comment>http://www.cppblog.com/LeafCore/comments/148292.html</wfw:comment><comments>http://www.cppblog.com/LeafCore/articles/148292.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/LeafCore/comments/commentRss/148292.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/LeafCore/services/trackbacks/148292.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一个简单的虚拟机，虚拟机有100个字的内存，几个寄存器&#8212;&#8212;指令计数器、指令寄存器、操作码寄存器、内存地址寄存器、累加寄存器。可以&#8212;&#8212;输入01、输出02、加载数据到寄存器03、存放数据到内存04、简单的加05减06乘07除08运算、转移09、小于零转移10、等于零转移11、终止12。程序输入完，输入0000结束。&nbsp;打印两个数中的较大数...&nbsp;&nbsp;<a href='http://www.cppblog.com/LeafCore/articles/148292.html'>阅读全文</a><img src ="http://www.cppblog.com/LeafCore/aggbug/148292.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/LeafCore/" target="_blank">LeafCore</a> 2011-06-08 19:17 <a href="http://www.cppblog.com/LeafCore/articles/148292.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>