<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
<title><![CDATA[Ac的幸福……]]></title>
        <image>
        <title>http://hi.baidu.com</title>
        <link>http://hi.baidu.com</link>
        <url>http://img.baidu.com/img/logo-hi.gif</url>
        </image>
<description><![CDATA[清泉浮锦鲤，碧空止祥云，朝露尚还冰，人影稍未停]]></description>
<link>http://hi.baidu.com/wangyucao1989</link>
<language>zh-cn</language>
<generator>www.baidu.com</generator>
<ttl>5</ttl>


<item>
        <title><![CDATA[最近。。。]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/289533cd9cc28b580fb345a0.html]]></link>
        <description><![CDATA[
		
		<p>最近，考试很疯狂，大四的学长和朋友们即将离校也让人很舍不得，不过，他们毕竟是迈向更长远，更广阔的未来了，祝福你们了，TBK，ChristX, CX, CTQY , Gohan ,LXM，希望你们以后都能越走越顺畅啦，呵呵。lycdragon，ufoxliu，加油啦，我们自己人就不说啥了，呵呵！</p>
<p>考试，考了两门，还有三门，预计6月30号放假，不过目前来说，放假意味着考研准备的疯狂开始。其实，终点就是起点，我很清楚，完成承诺，然后努力复习，这就是我该做的，至于之前百度实习生的事情，笔试下来面试，呵呵，一面还可以吧，不过二面搞砸啦，应该是没戏了，那天的状态真是不好~顺便，我还是更喜欢百度一面的面试官，姓刘，人挺好，说话很清楚。</p>
<p>就这些，另外，最近有个对我很重要的日子，希望能顺利！</p>
<p>人生就是这样，但是我坚持认为未来会是好的，呵呵！</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/289533cd9cc28b580fb345a0.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%D2%BB%D0%A9%CF%EB%B7%A8">一些想法</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/289533cd9cc28b580fb345a0.html#comment">查看评论</a>]]></description>
        <pubDate>2009-06-20  23:44</pubDate>
        <category><![CDATA[一些想法]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/289533cd9cc28b580fb345a0.html</guid>
</item>

<item>
        <title><![CDATA[pku2503 Babelfish]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/2746f8f5c685132dbc310997.html]]></link>
        <description><![CDATA[
		
		<div class="ptt" align="center"><font size="5">Babelfish</font></div>
<div class="plm">
<table align="center">
    <tbody>
        <tr>
            <td><strong>Time Limit:</strong> 3000MS</td>
            <td width="10"> </td>
            <td><strong>Memory Limit:</strong> 65536K</td>
        </tr>
        <tr>
            <td><strong>Total Submissions:</strong> 9371</td>
            <td width="10"> </td>
            <td><strong>Accepted:</strong> 4083</td>
        </tr>
    </tbody>
</table>
</div>
<p class="pst">Description</p>
<div class="ptx">You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.</div>
<p class="pst">Input</p>
<div class="ptx">Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.</div>
<p class="pst">Output</p>
<div class="ptx">Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as &quot;eh&quot;.</div>
<p class="pst">Sample Input</p>
<pre class="sio">dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay</pre>
<p class="pst">Sample Output</p>
<pre class="sio">cat
eh
loops</pre>
<p class="pst">Hint</p>
<div class="ptx">
<p>Huge input and output,scanf and printf are recommended.</p>
<p>这道题有好多种解法，开始试着用map做了，不过这样就变的很水了，大概用了1200+ms。</p>
<p>后来改成用trie写了，自己随便写的，所以效率不高，不过还是500+ms就过了。比map快多了。</p>
</div>
<p>/*<br>
ID :wangyucao<br>
PROB:pku2503_Babelfish<br>
LANG:C++<br>
*/<br>
#include &lt;iostream&gt;<br>
#include &lt;cstring&gt;<br>
#include &lt;stdlib.h&gt;<br>
#include &lt;algorithm&gt;<br>
using namespace std;<br>
//FILE *f=fopen(&quot;c.2.dat&quot;,&quot;r&quot;);<br>
//FILE *fp=fopen(&quot;c.txt&quot;,&quot;w&quot;);<br>
struct Node<br>
{<br>
 Node* ch[26];<br>
 char s[12];<br>
 Node()<br>
 {<br>
&nbsp;&nbsp; for(int i=0;i&lt;26;i++)<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; ch[i]=NULL;<br>
&nbsp;&nbsp;&nbsp; strcpy(s,&quot;&quot;);<br>
&nbsp;&nbsp; }<br>
 }<br>
 ~Node()<br>
 {<br>
&nbsp;&nbsp; int i;<br>
&nbsp;&nbsp; for(i=0;i&lt;26;i++)<br>
&nbsp;&nbsp;&nbsp; if(this-&gt;ch[i]!=NULL)<br>
&nbsp;&nbsp;&nbsp;&nbsp; delete this-&gt;ch[i];<br>
 }<br>
};<br>
Node *T;<br>
char s[12],st[12];<br>
void InsertT(Node* Tr,int i)<br>
{<br>
 int j;<br>
 if(i==strlen(s))<br>
 {<br>
&nbsp;&nbsp; strcpy(Tr-&gt;s,st);<br>
&nbsp;&nbsp; return;<br>
 }<br>
 if(Tr-&gt;ch[s[i]-'a']!=NULL)<br>
&nbsp;&nbsp; InsertT(Tr-&gt;ch[s[i]-'a'],i+1);<br>
 else <br>
 {<br>
&nbsp;&nbsp; Node *p;<br>
&nbsp;&nbsp; p=new Node;<br>
&nbsp;&nbsp; Tr-&gt;ch[s[i]-'a']=p;<br>
&nbsp;&nbsp; InsertT(Tr-&gt;ch[s[i]-'a'],i+1);<br>
 }<br>
}<br>
void FoundT(Node *Tr,int i)<br>
{<br>
 if(i==strlen(s))<br>
 {<br>
&nbsp;&nbsp; strcpy(st,Tr-&gt;s);<br>
&nbsp;&nbsp; return;<br>
 }<br>
 if(Tr-&gt;ch[s[i]-'a']!=NULL)<br>
 {<br>
&nbsp;&nbsp; FoundT(Tr-&gt;ch[s[i]-'a'],i+1);<br>
 }<br>
}<br>
int main()<br>
{<br>
 int i,j;<br>
 char c;<br>
 T=new Node;<br>
 scanf(&quot;%c&quot;,&amp;c);<br>
 while(c!='\n')<br>
 {<br>
&nbsp;&nbsp; scanf(&quot;%s%s&quot;,st+1,s);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  st[0]=c;<br>
&nbsp;&nbsp; scanf(&quot;%c&quot;,&amp;c);&nbsp;&nbsp;<br>
&nbsp;&nbsp; InsertT(T,0);<br>
&nbsp;&nbsp; scanf(&quot;%c&quot;,&amp;c); <br>
 }<br>
 while(scanf(&quot;%s&quot;,s)!=EOF)<br>
 {<br>
&nbsp;&nbsp; st[0]='\0';<br>
&nbsp;&nbsp; FoundT(T,0);<br>
&nbsp;&nbsp; if(strlen(st)==0)<br>
&nbsp;&nbsp;&nbsp; strcpy(st,&quot;eh&quot;);<br>
&nbsp;&nbsp; printf(&quot;%s\n&quot;,st);<br>
 }<br>
 return 0;<br>
}</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/2746f8f5c685132dbc310997.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/acm%26%2347%3Bicpc">acm&#47;icpc</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/2746f8f5c685132dbc310997.html#comment">查看评论</a>]]></description>
        <pubDate>2009-04-26  23:29</pubDate>
        <category><![CDATA[acm&#47;icpc]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/2746f8f5c685132dbc310997.html</guid>
</item>

<item>
        <title><![CDATA[过年。。。]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/a1516435c8944e8ca61e1282.html]]></link>
        <description><![CDATA[
		
		<p>难得有机会上网，赶紧偷空来博客更新一下，呵呵。</p>
<p>回家以后刚开始真的蛮无聊，不过玩的也蛮High的，你想啊，早上11多才起床，起来后洗了脸就可以吃午饭了，吃完饭开始玩电脑游戏，把NBA的王朝模式玩了好几遍，姚明在我手上都退役很多次了，呵呵。从腊月25号开始我就没那么轻松了，一般每天都要打扫房间，收拾东西，买年货。最忙的就是大年三十了，我要擦桌子，贴对联，挂灯笼，摆献果，呵呵。晚上一家人吃火锅，真的很不错。就在那天晚上，小沈阳火了。。。</p>
<p>年后直到初五都是要走亲戚的，过了这几天开始没事干了，但是一没事干又觉得无聊了～游戏都不想打了，呵呵。经常打打长途电话，难得上次网，找个能视频的地方，还待不了多久。。。同学聚会，看见了高中和初中的不少关系很好的同学，聊聊天，时间就过去了。这些天基本上没怎么出门。看看小连能到处转转，真的是挺羡慕的，嘿嘿。小蜗牛都回西安了，找到工作做了，真好。不过，有个人回家后发现变的跟我一样了，^_^，也能睡到大中午了，她还感冒了，要多注意身体，这不知道是我第几次说这句话了。。。</p>
<p>总之，祝大家过年都开开心心，万事如意啦！当然，最重要的还是身体健康！好了，希望你们都能早点回来，嘿嘿，牛年大吉。。。</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/a1516435c8944e8ca61e1282.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%D2%BB%D0%A9%CF%EB%B7%A8">一些想法</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/a1516435c8944e8ca61e1282.html#comment">查看评论</a>]]></description>
        <pubDate>2009-02-05  10:11</pubDate>
        <category><![CDATA[一些想法]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/a1516435c8944e8ca61e1282.html</guid>
</item>

<item>
        <title><![CDATA[开心]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/6ba972efc4700611fdfa3c86.html]]></link>
        <description><![CDATA[
		
		<p>因为她的生日，所以很开心。。。</p>
<p>希望大家2009年都能开开心心！</p>
<p>给大家拜个早年，回家不能上网，就不能拜年了。。。</p>
<p>2009，新年好~</p> 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%D2%BB%D0%A9%CF%EB%B7%A8">一些想法</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/6ba972efc4700611fdfa3c86.html#comment">查看评论</a>]]></description>
        <pubDate>2009-01-11  00:05</pubDate>
        <category><![CDATA[一些想法]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/6ba972efc4700611fdfa3c86.html</guid>
</item>

<item>
        <title><![CDATA[STL中的生成排列next_permutation()。。。]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/ae763ec47f470eae8226ac1e.html]]></link>
        <description><![CDATA[
		
		<p>今天看了看TC里面的一道题，简单的说，就是给你一个字符串，要求你用这个字符串的同构，来生成一种Lucky String ，所谓Lucky String 就是字符串中任意相邻两个字母都是不相同的。</p>
<p>开始一直在想用组合数学怎么做，后来看到字符串只有最大10的范围，所以决定穷举。要穷举就要生成排列，自己写效率不会太高，突然看到STL中提供的一个函数：next_permutation</p>
<p>这是一个好东西啊，比如一个字母序列，你要生成这个序列的所有排列，可以这样：</p>
<p>char a[10];</p>
<p>do{</p>
<p>&nbsp;&nbsp;&nbsp;  for(i=0;i&lt;10;i++) cout&lt;&lt;a[i]&lt;&lt;' ';</p>
<p>}while(next_permutation(a,a+10));</p>
<p>这样使用简单，代码看起来很漂亮，嘿嘿~</p>
<p>当然，这个next_permutation函数需要包含algorithm头文件。另外还提供了prev_permutation，前者是按照开始从小到大排列后生成的，后者这是从大到小。挺好用的，所以记下来！</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/ae763ec47f470eae8226ac1e.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/acm%26%2347%3Bicpc">acm&#47;icpc</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/ae763ec47f470eae8226ac1e.html#comment">查看评论</a>]]></description>
        <pubDate>2008-12-04  14:01</pubDate>
        <category><![CDATA[acm&#47;icpc]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/ae763ec47f470eae8226ac1e.html</guid>
</item>

<item>
        <title><![CDATA[无聊时写给别人的……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/e0957a516f09b9888d54302a.html]]></link>
        <description><![CDATA[
		
		<p>//实现简单的学生成绩信息管理软件。 <br>
//学生信息包括：学号、姓名、4 门课程的成绩（计算机，数学，英语，物理） 。 <br>
//要实现的功能：学生信息的录入、修改、删除和查询。 <br>
#include&lt;iostream&gt;<br>
#include&lt;string&gt;<br>
#include&lt;fstream&gt;<br>
#include&lt;cmath&gt;<br>
#include&lt;iomanip&gt;<br>
#include&lt;stack&gt;<br>
#define STU_NUM 100<br>
using namespace std;<br>
struct stu{<br>
 string name;<br>
 string no;<br>
 int score[4];<br>
 double aver;<br>
}stu[STU_NUM];<br>
bool stuin[STU_NUM];<br>
stack&lt;int&gt; s;<br>
int n,stunum;<br>
string strfind;<br>
ifstream fin(&quot;stu.dat&quot;,ios::in);<br>
void showmenu()<br>
{<br>
 cout&lt;&lt;&quot;*********************************&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot; 请选择你需要的功能&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;1.录入学生信息&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;2.修改学生信息&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;3.查询学生信息&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;4.删除学生信息&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;5.退出&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;**********************************&quot;&lt;&lt;endl;<br>
}<br>
void display(int i)<br>
{<br>
 cout&lt;&lt;&quot;学号:&quot;;<br>
 cout&lt;&lt;stu[i].no&lt;&lt;endl;;<br>
 cout&lt;&lt;&quot;姓名:&quot;;<br>
 cout&lt;&lt;stu[i].name&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;计算机成绩:&quot;;<br>
 cout&lt;&lt;stu[i].score[0]&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;数学成绩:&quot;;<br>
 cout&lt;&lt;stu[i].score[1]&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;英语成绩:&quot;;<br>
 cout&lt;&lt;stu[i].score[2]&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;物理成绩:&quot;;<br>
 cout&lt;&lt;stu[i].score[3]&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;平均成绩:&quot;&lt;&lt;endl;<br>
 cout&lt;&lt;setiosflags(ios::fixed)&lt;&lt;setprecision(1)&lt;&lt;stu[i].aver&lt;&lt;endl;<br>
}<br>
void Inserts()<br>
{<br>
 int i;<br>
 for(i=0;i&lt;n;i++) if(!stuin[i]) break;<br>
 cout&lt;&lt;&quot;您选择了插入信息&quot;&lt;&lt;endl;<br>
 cout&lt;&lt;&quot;请输入要插入学生的学号:&quot;;<br>
 cin&gt;&gt;stu[i].no;<br>
 cout&lt;&lt;&quot;请输入要插入学生的姓名:&quot;;<br>
 cin&gt;&gt;stu[i].name;<br>
 cout&lt;&lt;&quot;请输入要插入学生的计算机成绩:&quot;;<br>
 cin&gt;&gt;stu[i].score[0];<br>
 cout&lt;&lt;&quot;请输入要插入学生的数学成绩:&quot;;<br>
 cin&gt;&gt;stu[i].score[1];<br>
 cout&lt;&lt;&quot;请输入要插入学生的英语成绩:&quot;;<br>
 cin&gt;&gt;stu[i].score[2];<br>
 cout&lt;&lt;&quot;请输入要插入学生的物理成绩:&quot;;<br>
 cin&gt;&gt;stu[i].score[3];<br>
 stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3])*1.0/4;<br>
 stuin[i]=true;<br>
 if(i==n) {n++; stunum++;}<br>
 cout&lt;&lt;&quot;插入成功！&quot;&lt;&lt;endl;<br>
}<br>
int Searchs(int mod=0)<br>
{<br>
 if(mod!=0){<br>
&nbsp;&nbsp; for(int i=0;i&lt;n;i++)<br>
&nbsp;&nbsp;&nbsp; if(stuin &amp;&amp; !stu[i].no.compare(strfind))<br>
&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp; if(i&lt;n) return i;<br>
&nbsp;&nbsp; else return -1;<br>
 }<br>
 else{<br>
&nbsp;&nbsp; cout&lt;&lt;&quot;请输入您要查找的学生的学号:&quot;;<br>
&nbsp;&nbsp; cin&gt;&gt;strfind;<br>
&nbsp;&nbsp; for(int i=0;i&lt;n;i++)<br>
&nbsp;&nbsp;&nbsp; if(!stu[i].no.compare(strfind))<br>
&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp; if(i&gt;=n) cout&lt;&lt;&quot;要查找的学生不存在！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; else display(i);<br>
 }<br>
 return 0;<br>
}<br>
void Modifys()<br>
{<br>
 cout&lt;&lt;&quot;请输入您要修改的学生学号:&quot;&lt;&lt;endl;<br>
 cin&gt;&gt;strfind;<br>
 int i=Searchs(1);<br>
 int j;<br>
 if(i&lt;0) {cout&lt;&lt;&quot;您要修改的学生不存在！请确认后在执行修改！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp;  return ;<br>
&nbsp;&nbsp;&nbsp;  }<br>
 cout&lt;&lt;&quot;要修改学生的当前信息&quot;&lt;&lt;endl;<br>
 display(i);<br>
 cout&lt;&lt;&quot;请选择要修改的项目：&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;1.学号&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;2.姓名&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;3.计算机成绩&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;4.数学成绩&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;5.物理成绩&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;6.英语成绩&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;可多选，用空格隔开！最后以数字0结尾&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; while(cin&gt;&gt;j &amp;&amp; j&gt;0) s.push(j);<br>
&nbsp;&nbsp; if(!s.empty()) cout&lt;&lt;&quot;请输入修改后的信息：&quot;;<br>
&nbsp;&nbsp; while(!s.empty()){<br>
&nbsp;&nbsp;&nbsp; switch(s.top()){<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 1: cout&lt;&lt;&quot;学号:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].no;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 2: cout&lt;&lt;&quot;姓名:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].name;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 3: cout&lt;&lt;&quot;计算机成绩:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].score[0];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 4: cout&lt;&lt;&quot;数学成绩:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].score[1];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 5: cout&lt;&lt;&quot;英语成绩:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].score[2];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp; case 6: cout&lt;&lt;&quot;物理成绩:&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cin&gt;&gt;stu[i].score[3];<br>
&nbsp;&nbsp;&nbsp; } <br>
&nbsp;&nbsp;&nbsp; if(s.top() &gt; 2) <br>
&nbsp;&nbsp;&nbsp;&nbsp; stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3])*1.0/4;<br>
&nbsp;&nbsp;&nbsp; s.pop();<br>
&nbsp;&nbsp; }<br>
 cout&lt;&lt;&quot;修改成功，修改后学生的信息：&quot;&lt;&lt;endl;<br>
 display(i);<br>
}</p>
<p>void Deletes()<br>
{<br>
 cout&lt;&lt;&quot;请输入您要删除的学生学号:&quot;&lt;&lt;endl;<br>
 cin&gt;&gt;strfind;<br>
 int i=Searchs(1);<br>
 if(i&lt;0) {cout&lt;&lt;&quot;您要删除的学生不存在！请确认后在执行删除！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp;  return ;<br>
&nbsp;&nbsp;&nbsp;  }<br>
 stuin[i]=false;<br>
 stunum--;<br>
}<br>
void savedata()<br>
{<br>
 ofstream fout(&quot;stu.dat&quot;);<br>
 for(int i=0;i&lt;n;i++)<br>
&nbsp;&nbsp; if(stuin[i]){&nbsp;&nbsp;<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].no&lt;&lt;endl;;<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].name&lt;&lt;endl;<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].score[0]&lt;&lt;' ';<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].score[1]&lt;&lt;' ';<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].score[2]&lt;&lt;' ';<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].score[3]&lt;&lt;' ';<br>
&nbsp;&nbsp; fout&lt;&lt;stu[i].aver&lt;&lt;endl;<br>
&nbsp;&nbsp; }<br>
}<br>
int main()<br>
{<br>
 int i,j,k,ch;<br>
 string stna,stno;<br>
 memset(stuin,false,sizeof(stuin));<br>
 stunum=n=i=0;<br>
 cout&lt;&lt;&quot;正在导入学生信息文件......&quot;;<br>
 if(fin.fail()) cout&lt;&lt;endl&lt;&lt;&quot;学生信息文件不存在！&quot;&lt;&lt;endl;<br>
 else{<br>
&nbsp;&nbsp; while(!fin.eof()){<br>
&nbsp;&nbsp;&nbsp; fin&gt;&gt;stu[i].no&gt;&gt;stu[i].name;<br>
&nbsp;&nbsp;&nbsp; for(j=0;j&lt;4;j++)<br>
&nbsp;&nbsp;&nbsp;&nbsp; fin&gt;&gt;stu[i].score[j];<br>
&nbsp;&nbsp;&nbsp; fin&gt;&gt;stu[i].aver;<br>
&nbsp;&nbsp;&nbsp; stuin[i]=true;<br>
&nbsp;&nbsp;&nbsp; i++;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; cout&lt;&lt;endl&lt;&lt;&quot;OK!&quot;&lt;&lt;endl;&nbsp;&nbsp;<br>
&nbsp;&nbsp; stunum=n=i-1;<br>
&nbsp;&nbsp; cout&lt;&lt;stunum&lt;&lt;&quot;个学生信息现在在学生文件中！&quot;&lt;&lt;endl; <br>
 }<br>
 fin.close();<br>
 while(1)<br>
 {<br>
&nbsp;&nbsp; bool flag=false;<br>
&nbsp;&nbsp; showmenu();<br>
&nbsp;&nbsp; cin&gt;&gt;ch;<br>
&nbsp;&nbsp; if(ch==5) break;<br>
&nbsp;&nbsp; switch(ch){<br>
&nbsp;&nbsp;&nbsp; case 1: Inserts(); break;<br>
&nbsp;&nbsp;&nbsp; case 2: Modifys(); break;<br>
&nbsp;&nbsp;&nbsp; case 3: Searchs(); break;<br>
&nbsp;&nbsp;&nbsp; case 4: Deletes(); break;<br>
&nbsp;&nbsp;&nbsp; default: cout&lt;&lt;&quot;输入不正确，请重新选择！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getchar();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag=true;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; if(flag) continue;<br>
 }<br>
 savedata();<br>
 return 0;<br>
}</p>
<p> </p>
<p>/*<br>
2、 编写小学生数学测试软件。 <br>
(1)  可选择题型加，减，乘。 <br>
(2)  可选择每次答题的个数。 <br>
(3)  随机生成两个数进行运算。 <br>
(4)  每次输入答案后判断对错，若答案错误，给出正确答案。 <br>
(5)  最后给出做对题目的总个数。 <br>
*/<br>
#include&lt;iostream&gt;<br>
#include&lt;fstream&gt;<br>
#include&lt;iomanip&gt;<br>
#include&lt;time.h&gt;<br>
#include&lt;cstdlib&gt;<br>
using namespace std;<br>
const int maxn=1000;  //设置加法，减法的最大数，这里设置为1000<br>
const int maxn2=100;  //设置乘法的最大数，这里设置为100<br>
int n;<br>
void plusfunc()<br>
{<br>
 int a,b,c;<br>
 int score=0;<br>
 while(n--){<br>
&nbsp;&nbsp; a=rand()%(maxn+1);<br>
&nbsp;&nbsp; b=rand()%(maxn+1);<br>
&nbsp;&nbsp; cout&lt;&lt;a&lt;&lt;&quot; + &quot;&lt;&lt;b&lt;&lt;&quot;= &quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; cin&gt;&gt;c;<br>
&nbsp;&nbsp; if(c==a+b) {<br>
&nbsp;&nbsp;&nbsp; cout&lt;&lt;&quot;回答正确，加十分！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp; score+=1;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; else cout&lt;&lt;&quot;答错了！正确答案是： &quot;&lt;&lt;a+b&lt;&lt;endl;<br>
 }<br>
 cout&lt;&lt;&quot;您答对了 &quot;&lt;&lt;score&lt;&lt;&quot; 个题目，得分为&quot;&lt;&lt;score*10&lt;&lt;&quot; 分！&quot;&lt;&lt;endl;<br>
}<br>
void subfunc()<br>
{<br>
 int a,b,c;<br>
 int score=0;<br>
 while(n--){<br>
&nbsp;&nbsp; a=rand()%(maxn+1);<br>
&nbsp;&nbsp; b=rand()%(maxn+1);<br>
&nbsp;&nbsp; if(a&lt;b) swap(a,b);<br>
&nbsp;&nbsp; cout&lt;&lt;a&lt;&lt;&quot; - &quot;&lt;&lt;b&lt;&lt;&quot;= &quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; cin&gt;&gt;c;<br>
&nbsp;&nbsp; if(c==a-b) {<br>
&nbsp;&nbsp;&nbsp; cout&lt;&lt;&quot;回答正确，加十分！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp; score+=1;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; else cout&lt;&lt;&quot;答错了！正确答案是： &quot;&lt;&lt;a-b&lt;&lt;endl;<br>
 }<br>
 cout&lt;&lt;&quot;您答对了 &quot;&lt;&lt;score&lt;&lt;&quot; 个题目，得分为&quot;&lt;&lt;score*10&lt;&lt;&quot; 分！&quot;&lt;&lt;endl;<br>
}<br>
void multifunc()<br>
{<br>
 int a,b,c;<br>
 int score=0;<br>
 while(n--){<br>
&nbsp;&nbsp; a=rand()%(maxn2+1);<br>
&nbsp;&nbsp; b=rand()%(maxn2+1);<br>
&nbsp;&nbsp; cout&lt;&lt;a&lt;&lt;&quot; * &quot;&lt;&lt;b&lt;&lt;&quot;= &quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; cin&gt;&gt;c;<br>
&nbsp;&nbsp; if(c==a*b) {<br>
&nbsp;&nbsp;&nbsp; cout&lt;&lt;&quot;回答正确，加十分！&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp; score+=1;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; else cout&lt;&lt;&quot;答错了！正确答案是： &quot;&lt;&lt;a*b&lt;&lt;endl;<br>
 }<br>
 cout&lt;&lt;&quot;您答对了 &quot;&lt;&lt;score&lt;&lt;&quot; 个题目，得分为 &quot;&lt;&lt;score*10&lt;&lt;&quot; 分！&quot;&lt;&lt;endl;<br>
}<br>
int main()<br>
{<br>
 int i,j,k;<br>
 cout&lt;&lt;&quot;请选择要做的题型：&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;1.加法&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;2.减法&quot;&lt;&lt;endl<br>
&nbsp;&nbsp; &lt;&lt;&quot;3.乘法&quot;&lt;&lt;endl;<br>
 cin&gt;&gt;k;<br>
 cout&lt;&lt;&quot;请选择要做的题目个数：&quot;;<br>
 cin&gt;&gt;n;<br>
 srand((unsigned) time(0)); <br>
 switch(k){<br>
&nbsp;&nbsp; case 1: plusfunc(); break;<br>
&nbsp;&nbsp; case 2: subfunc(); break;<br>
&nbsp;&nbsp; case 3: multifunc();break;<br>
&nbsp;&nbsp; default: cout&lt;&lt;&quot;输入错误，程序结束！&quot;;<br>
 }<br>
 return 0;<br>
}</p>
<p> </p>
<p>/*<br>
5、 打印如下方阵（任选一题）。 <br>
(1)  螺旋方阵：&nbsp;&nbsp;  <br>
1&nbsp;&nbsp;&nbsp;  2&nbsp;&nbsp;&nbsp;  3&nbsp;&nbsp;&nbsp;  4&nbsp;&nbsp;  <br>
12  13  14  5 <br>
11  16  15  6 <br>
10  9&nbsp;&nbsp;&nbsp;  8&nbsp;&nbsp;&nbsp;  7 <br>
*/<br>
#include&lt;iostream&gt;<br>
#include&lt;fstream&gt;<br>
#include&lt;string&gt;<br>
#include&lt;algorithm&gt;<br>
#include&lt;iomanip&gt;<br>
using namespace std;<br>
int n,dirnow,cnt;<br>
int a[101][101];<br>
bool filla[101][101];<br>
int dir[4][2]={0,1,1,0,0,-1,-1,0};<br>
void dfs(int i,int j)<br>
{<br>
 int x;<br>
 int y;<br>
 if(cnt==n*n) return; <br>
 dirnow%=4;<br>
 x=i+dir[dirnow][0];<br>
 y=j+dir[dirnow][1];<br>
 if(x&lt;0 || x&gt;=n || y&lt;0 || y&gt;=n || filla[x][y])<br>
&nbsp;&nbsp; dirnow++;<br>
 dirnow%=4;<br>
 cnt++;<br>
 filla[i+dir[dirnow][0]][j+dir[dirnow][1]]=true;<br>
 a[i+dir[dirnow][0]][j+dir[dirnow][1]]=cnt;<br>
 dfs(i+dir[dirnow][0],j+dir[dirnow][1]);<br>
}<br>
int main()<br>
{<br>
 int i,j;<br>
 cout&lt;&lt;&quot;请输入要打印螺旋矩阵的维数:&quot;;<br>
 cin&gt;&gt;n;<br>
 memset(filla,false,sizeof(filla));<br>
 a[0][0]=1;<br>
 filla[0][0]=true;<br>
 dirnow=0;<br>
 cnt=1;<br>
 dfs(0,0);<br>
 for(i=0;i&lt;n;i++){<br>
&nbsp;&nbsp; for(j=0;j&lt;n;j++){<br>
&nbsp;&nbsp;&nbsp; cout&lt;&lt;a[i][j]&lt;&lt;&quot;\t&quot;;<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; cout&lt;&lt;endl;<br>
 }<br>
 return 0;<br>
}</p>
<p> </p>
<p>/*<br>
7、 假定用一个整型数组表示一个长整数，数组的每个元素存储长整数的一位数字，实际的<br>
长整数 m表示为： <br>
m=a[k]× 10-1+a[k-1]× 10-2+….+a[2]×10+a[1] <br>
其中 a[0]保存该长整数的位数。完成（任选一题） ： <br>
(1)  长整数乘普通整数。 <br>
(2)  长整数除普通整数。 <br>
*/<br>
#include&lt;iostream&gt;<br>
#include&lt;fstream&gt;<br>
#include&lt;string&gt;<br>
#include&lt;algorithm&gt;<br>
using namespace std;<br>
string operator*(string s, int a); // s,a非负，且a必须小于2*10^8.<br>
string MSDiv(string x, int y, int &amp;res); // 多精度除以int，x非负，y为正<br>
string operator/(string s, int a); // 调用MSDiv<br>
string Head_zero_remover(string num); // 除了开头可能有'0'外，num必须是非负数。<br>
bool Less(string x, string y); // 非负数之间的&quot;小于&quot;</p>
<p>string operator-(string s); // 取负<br>
string SAdd(string x, string y);<br>
string SMinus(string x, string y);<br>
string SMul(string x, string y);<br>
string SMul(string s, int a);&nbsp;&nbsp; // 同样，a的绝对值不能超过2*10^8<br>
string operator*(string s, int a)<br>
{<br>
 if(s == &quot;0&quot; || a == 0) // 以免后面特殊处理！<br>
&nbsp;&nbsp; return &quot;0&quot;;&nbsp;&nbsp;</p>
<p> string prod(s.size(), -1); // 先申请s.size()位<br>
 <br>
 int carry=0;<br>
 for(int i=s.size()-1; i &gt;= 0; --i)<br>
 {<br>
&nbsp;&nbsp; carry += (s[i]-'0')*a;<br>
&nbsp;&nbsp; prod[i] = carry%10+'0';<br>
&nbsp;&nbsp; carry /= 10;<br>
 }<br>
 while(carry&gt;0)<br>
 {<br>
&nbsp;&nbsp; prod.insert(prod.begin(), carry%10+'0');<br>
&nbsp;&nbsp; carry /= 10;<br>
 }</p>
<p> return prod;<br>
}<br>
string MSDiv(string x, int y, int &amp;res)<br>
{<br>
 string quot(x.size(), 0);</p>
<p> res=0;<br>
 for(int i=0; i&lt;x.size(); ++i)<br>
 {<br>
&nbsp;&nbsp; res = 10*res+x[i]-'0';<br>
&nbsp;&nbsp; quot[i] = res/y+'0'; // 整除结果为商<br>
&nbsp;&nbsp; res %= y; // 取余保留<br>
 }<br>
 return Head_zero_remover(quot);<br>
}<br>
string operator/(string s, int a)<br>
{<br>
 int res;<br>
 return MSDiv(s, a, res);<br>
}<br>
string Head_zero_remover(string num) // 化简&quot;003&quot;等数<br>
{<br>
 if(num[0] != '0')<br>
&nbsp;&nbsp; return num;<br>
 int pos=num.find_first_not_of('0');<br>
 if(pos == string::npos) // 全0<br>
&nbsp;&nbsp; return &quot;0&quot;;<br>
 return num.substr(pos, num.size()-pos);<br>
}<br>
string operator-(string s)<br>
{<br>
 if(s[0] == '-')<br>
&nbsp;&nbsp; return s.substr(1, s.size()-1);<br>
 if(s == &quot;0&quot;)<br>
&nbsp;&nbsp; return &quot;0&quot;;<br>
 return string(&quot;-&quot;) += s;<br>
}<br>
string SMul(string s, int a)<br>
{<br>
 if(s[0] == '-' &amp;&amp; a&lt;0)<br>
&nbsp;&nbsp; return (-s)*(-a);<br>
 if(s[0] == '-')<br>
&nbsp;&nbsp; return -((-s)*a);<br>
 if(a&lt;0)<br>
&nbsp;&nbsp; return -(s*(-a));<br>
 return s * a;<br>
}<br>
int main()<br>
{<br>
 string s1;<br>
 int a;<br>
 cout&lt;&lt;&quot;请输入长整数：&quot;;<br>
 cin&gt;&gt;s1;<br>
 cout&lt;&lt;&quot;请输入普通整数：&quot;;<br>
 cin&gt;&gt;a;<br>
 cout&lt;&lt;s1&lt;&lt;&quot; * &quot;&lt;&lt;a&lt;&lt;&quot; = &quot;&lt;&lt;s1*a&lt;&lt;endl;<br>
 cout&lt;&lt;s1&lt;&lt;&quot; / &quot;&lt;&lt;a&lt;&lt;&quot; = &quot;&lt;&lt;s1/a&lt;&lt;endl;<br>
 return 0;<br>
}</p>
<p> </p>
<p>/*<br>
9、 算法问题（任选一题） 。 <br>
(1)  皇后问题：在国际象棋中，能否在空棋盘上摆放八个皇后，并使其中任意两个皇后<br>
不能在同一行或同一列或同一对角线上，并编写完整的摆放八皇后问题的程序。要求：<br>
第一个皇后的起始位置由键盘输入，国际象棋的棋盘为 8*8 的方格。 <br>
*/<br>
  #include&lt;iostream&gt;&nbsp;&nbsp;  <br>
  using namespace std;<br>
  bool&nbsp;&nbsp;  Col[8],LeftCr[16],RightCr[16],Row[8];&nbsp;&nbsp;  <br>
  short&nbsp;&nbsp;  Answer[8],Count=0;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  <br>
  /*Col{行标志定义}&nbsp;&nbsp;  <br>
  Answer{列标志定义}&nbsp;&nbsp;  <br>
  LeftCr{左斜对角线标志定义}&nbsp;&nbsp;  <br>
  RightCr{右斜对角线标志定义}&nbsp;&nbsp;  <br>
  {Count:解的个数纪录}&nbsp;&nbsp;  <br>
  */&nbsp;&nbsp;  <br>
  //-------------------------判断一个位置是否可以置一个皇后-----------------------&nbsp;&nbsp;  <br>
  bool&nbsp;&nbsp;  IfSafe(short&nbsp;&nbsp;  x,short&nbsp;&nbsp;  y)&nbsp;&nbsp;  <br>
  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  return&nbsp;&nbsp;  ((Col[y]==true)&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ||&nbsp;&nbsp;  (LeftCr[x-y+7]==true)&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ||&nbsp;&nbsp;  (RightCr[x+y]==true))?false:true;&nbsp;&nbsp;  <br>
  }&nbsp;&nbsp;  <br>
  //-----------------------------从当前位置删除一个皇后--------------------------&nbsp;&nbsp;  <br>
  void&nbsp;&nbsp;  CutQueen(short&nbsp;&nbsp;  x,short&nbsp;&nbsp;  y)&nbsp;&nbsp;  <br>
  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Col[y]=false;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  LeftCr[x-y+7]=false;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  RightCr[x+y]=false;&nbsp;&nbsp;  <br>
  }&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  <br>
  //---------------------------------打印一组解----------------------------------&nbsp;&nbsp;  <br>
  void&nbsp;&nbsp;  PrintAnswer()&nbsp;&nbsp;  <br>
  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  int&nbsp;&nbsp;  CurAns;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  printf(&quot;\nCOUNT[%4d]\n&quot;,++Count);&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  for&nbsp;&nbsp;  (CurAns=0;CurAns&lt;8;CurAns++) {<br>
&nbsp;&nbsp; for(int i=0;i&lt;8;i++)<br>
&nbsp;&nbsp;&nbsp; if(i==Answer[CurAns])<br>
&nbsp;&nbsp;&nbsp;&nbsp;  printf(&quot;Q&quot;);&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;  printf(&quot;.&quot;);<br>
&nbsp;&nbsp; printf(&quot;\n&quot;);<br>
 }<br>
  }&nbsp;&nbsp;  <br>
  //---------------------------------置皇后(核心部分)----------------------------&nbsp;&nbsp;  <br>
  void&nbsp;&nbsp;  PutQueen(short&nbsp;&nbsp;  x)&nbsp;&nbsp;  <br>
  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  short&nbsp;&nbsp;  y;&nbsp;&nbsp;  <br>
 if(x==8) PrintAnswer();<br>
 if(Row[x]) PutQueen(x+1);<br>
 else<br>
&nbsp;&nbsp;&nbsp;  for&nbsp;&nbsp;  (y=0;y&lt;8;y++)&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  if&nbsp;&nbsp;  (IfSafe(x,y))&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Answer[x]=y;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Col[y]=true;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  LeftCr[x-y+7]=true;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  RightCr[x+y]=true;&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  PutQueen(x+1);&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  CutQueen(x,y);&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }&nbsp;&nbsp;  <br>
  }&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;  <br>
  //--------------------主程序体--------------------------------------------&nbsp;&nbsp;  <br>
  int&nbsp;&nbsp;  main()&nbsp;&nbsp;  <br>
  {&nbsp;&nbsp;  <br>
&nbsp;&nbsp;  int x,y;<br>
  for&nbsp;&nbsp;  (int&nbsp;&nbsp;  i=0;i&lt;8;i++)&nbsp;&nbsp;  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Answer[i]=0;  <br>
  cout&lt;&lt;&quot;请输入第一行的皇后位置：&quot;;<br>
  cin&gt;&gt;x&gt;&gt;y;<br>
  x--;<br>
  y--;<br>
  Answer[x]=y; <br>
  Col[y]=true;&nbsp;&nbsp;  <br>
  Row[x]=true;<br>
  LeftCr[x-y+7]=true;&nbsp;&nbsp;  <br>
  RightCr[x+y]=true;&nbsp;&nbsp;  <br>
  PutQueen(0);&nbsp;&nbsp;  <br>
  return&nbsp;&nbsp;  0;&nbsp;&nbsp;  <br>
  }&nbsp;&nbsp;</p>
<p> </p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/e0957a516f09b9888d54302a.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/acm%26%2347%3Bicpc">acm&#47;icpc</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/e0957a516f09b9888d54302a.html#comment">查看评论</a>]]></description>
        <pubDate>2008-11-04  22:43</pubDate>
        <category><![CDATA[acm&#47;icpc]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/e0957a516f09b9888d54302a.html</guid>
</item>

<item>
        <title><![CDATA[收获失败……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/c7db9fed114362d2b31cb1c3.html]]></link>
        <description><![CDATA[
		
		<p>回来有几天了，一直没写日志。</p>
<p>这次哈尔滨之行又仅仅是一次公费旅游，仍然没有拿奖，但是感觉到获奖离我们如此的近，近到几乎可以触摸到！但几乎就是几乎，遗憾的是，我们自己没有把握到机会，过多的浪费时间使我们离获奖越来越远。</p>
<p>这是一次失败的教训，从一开始就是失败的，心态不好决定了这次不会有什么收获，可能也不能这么说，最起码，我们收获到一次失败！这次可以总结的东西太多太多了，不经历这次挫折，很多东西都看不到的！这可能就是必经之路吧。</p>
<p>说说哈尔滨吧，那地方虽然很冷，但是我感觉很漂亮，哈尔滨工程大学做的很好，除了那个学生宿舍不能洗澡，其他的都做的挺好的，他们2010年要举办World Final，我相信他们会举办成一届非常成功的比赛！13号那天工程大学组织选手们旅游，去了东北虎野生动物园，还去了太阳岛，都很漂亮，还买了点小东西，呵呵。</p>
<p>然后去了防洪纪念塔，吃了晚饭就去火车站了，单程32个小时，真是熬人，就这样结束了这次失败的旅程……</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/c7db9fed114362d2b31cb1c3.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/c7db9fed114362d2b31cb1c3.html#comment">查看评论</a>]]></description>
        <pubDate>2008-10-19  09:59</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/c7db9fed114362d2b31cb1c3.html</guid>
</item>

<item>
        <title><![CDATA[祝我好运……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/119c02cafc04d940f31fe722.html]]></link>
        <description><![CDATA[
		
		<p>要走了，今天晚上8点半的火车到哈尔滨。</p>
<p>按照安排是15号就回来了，单程32个小时的火车，真是熬人啊！火车上能做什么呢？</p>
<p>11号早上到吧，听说那边挺冷的，带上了衣服和药。</p>
<p>12号的比赛，祝自己好运！God bless me……</p>
<p>希望能有所突破吧……</p> 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%C4%AC%C8%CF%B7%D6%C0%E0">默认分类</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/119c02cafc04d940f31fe722.html#comment">查看评论</a>]]></description>
        <pubDate>2008-10-09  15:23</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/119c02cafc04d940f31fe722.html</guid>
</item>

<item>
        <title><![CDATA[usaco 5.5.2 Hidden Password]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/bc2b7834e1857cb1d0a2d31a.html]]></link>
        <description><![CDATA[
		
		<pre><center><h1>Hidden Password</h1></center><center>ACM South Eastern Europe -- 2003</center><p>Sometimes the programmers have very strange ways of hiding their passwords. Billy &quot;Hacker&quot; Geits chooses a string S composed of L (5 &lt;= L &lt;= 100,000) lowercase letters ('a'..'z') with length L. Then he makes and sorts all L-1 one-letter left cyclic shifts of the string. He then takes as a password one prefix of the lexicographically first of the obtained strings (including S).</p><p>For example consider the string &quot;alabala&quot;. The sorted cyclic one-letter left shifts (including the initial string) are:</p><p><br>aalabal <br>abalaal <br>alaalab <br>alabala <br>balaala <br>laalaba <br>labalaa</p><p>Lexicographically, first string is 'aalabal'. The first letter of this string ('a') is the 'a' that was in position 6 in the initial string (counting the first letter in the string as position 0).</p><p>Write a program that, for given string S, finds the start position of the first letter of the sorted list of cyclic shifts of the string. If the first element appears more than once in the sorted list, then the program should output the smallest possible initial position.</p><h3>PROGRAM NAME: hidden</h3><h3>INPUT FORMAT</h3><ul><li>Line 1: A single integer: L</li><li>Line 2..?: All L characters of the the string S, broken across lines such that each line has 72 characters except the last one, which might have fewer.</li></ul><h3>SAMPLE INPUT (file hidden.in)</h3><pre>7
alabala</pre>
<h3>OUTPUT FORMAT</h3>
<ul>
    <li>Line 1: A single integer that is the start position of the first letter, as described above.</li>
</ul>
<h3>SAMPLE OUTPUT (file hidden.out)</h3>
<pre>6</pre>
</pre>
<pre>USER: wang yucao [wangyuc2]
TASK: hidden
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.000 secs, 4016 KB]
   Test 2: TEST OK [0.011 secs, 4016 KB]
   Test 3: TEST OK [0.011 secs, 4012 KB]
   Test 4: TEST OK [0.011 secs, 4012 KB]
   Test 5: TEST OK [0.000 secs, 4012 KB]
   Test 6: TEST OK [0.011 secs, 4016 KB]
   Test 7: TEST OK [0.011 secs, 4016 KB]
   Test 8: TEST OK [0.065 secs, 4012 KB]
   Test 9: TEST OK [0.065 secs, 4016 KB]
   Test 10: TEST OK [0.076 secs, 4016 KB]
   Test 11: TEST OK [0.065 secs, 4012 KB]
   Test 12: TEST OK [0.000 secs, 4012 KB]
   Test 13: TEST OK [0.022 secs, 4012 KB]
   Test 14: TEST OK [0.011 secs, 4012 KB]

All tests OK.
<p>Your program ('hidden') produced all correct answers!  This is your
submission #5 for this problem.  <strong>Congratulations!</strong></p><p> </p><p>/*<br>PROB: hidden<br>LANG: C++<br>*/<br>/*<br>这道题事实上还是搜索，不过在过程中采用类似KMP中的思想，串是环形的，我们可以把串拷贝一遍放在后面。<br>然后，用st记录当前的起始位置，用maxn来记录最小串的起始位置，那么每次对比s[st+i]和s[maxn+i]<br>这样有三种情况：<br>1.s[maxn+i] &lt; s[st+i]，这表示之前记录的最小串小于当前位置的串，结束；<br>2.s[maxn+i] == s[st+i]， 表示这个字符位相等，那么i后移一位；<br>3.s[maxn+i] &gt; s[st+i]，这表示当前位置的字符串较小，应该更新最小串起始记录maxn为st，结束。<br>执行这个比较过程知道st&gt;=n<br>在这个过程中，如果出现情况1，那么这次退出后i表示这两个串的相同前缀数，st可以直接加上i；</p><p>特别注意，如果在比较过程中，i==n了，那表示有两个串是相同的，这样要直接退出，输出0，否则test11超时！<br>*/<br>#include&lt;iostream&gt;<br>#include&lt;fstream&gt;<br>#include&lt;cstring&gt;<br>#include&lt;memory&gt;<br>#include&lt;algorithm&gt;<br>#define cin fin<br>using namespace std;<br>ifstream fin(&quot;hidden.in&quot;);<br>ofstream fout(&quot;hidden.out&quot;);<br>char s[200002];<br>char s1[200002];<br>int next[200002];<br>int maxn,n,m;<br>char ch;<br>int st,en,st2;<br>int main()<br>{<br>&nbsp;&nbsp;&nbsp;  int i,j,k;<br> char a,b,c;<br> cin&gt;&gt;n;<br> cin.getline(s,100,'\n');<br> while(cin.getline(s1,100,'\n'))<br>&nbsp;&nbsp; strcat(s,s1);<br>&nbsp;&nbsp;&nbsp;  strcpy(s1,s);<br>&nbsp;&nbsp;&nbsp;  strcat(s,s1);<br> maxn=0;<br> ch=s[0];<br> st=1;<br> s[n]=s[0];<br> int stat;<br> while(st&lt;n)<br> {<br>&nbsp;&nbsp;&nbsp;&nbsp;  stat=0;<br>&nbsp;&nbsp; for(i=0;i&lt;n;i++){<br>&nbsp;&nbsp;&nbsp; if(s[maxn+i]&lt;s[st+i])<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  stat=-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  else if(s[maxn+i]&gt;s[st+i])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  stat=1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  if(i&lt;n &amp;&amp; stat&gt;0) {<br>&nbsp;&nbsp;&nbsp;&nbsp; maxn=st;<br>&nbsp;&nbsp;&nbsp;&nbsp; ch=s[st];<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  else if(i&lt;n &amp;&amp; stat&lt;0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  st+=i+1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  continue;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  else if(i==n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  stat=2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br>&nbsp;&nbsp;&nbsp; st++;<br> }<br> if(stat==2) fout&lt;&lt;'0'&lt;&lt;endl;<br> else fout&lt;&lt;maxn&lt;&lt;endl;<br> return 0;<br>}</p></pre> <a href="http://hi.baidu.com/wangyucao1989/blog/item/bc2b7834e1857cb1d0a2d31a.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Usaco">Usaco</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/bc2b7834e1857cb1d0a2d31a.html#comment">查看评论</a>]]></description>
        <pubDate>2008-10-06  18:03</pubDate>
        <category><![CDATA[Usaco]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/bc2b7834e1857cb1d0a2d31a.html</guid>
</item>

<item>
        <title><![CDATA[usaco 5.4.4 Betsy&#39;s Tour]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/7857d9d727b25bdba044df6c.html]]></link>
        <description><![CDATA[
		
		<pre><center><strong><font size="7">Betsy's Tour</font></strong><br><strong>Don Piele</strong> </center><p>A square township has been divided up into N<sup>2</sup> square plots (1 &lt;= N &lt;= 7). The Farm is located in the upper left plot and the Market is located in the lower left plot. Betsy takes her tour of the township going from Farm to Market by walking through every plot exactly once. Shown below is one possible tour for Betsy when N=3.</p><pre>----------------
|    |    |    |
| F**********  |
|    |    | *  |
------------*---
|    |    | *  |
|  *****  | *  |
|  * | *  | *  |
---*---*----*---
|  * | *  | *  |
|  M | ******  |
|    |    |    |
----------------</pre>
Write a program that will count how many unique tours Betsy can take in going from Farm to Market for any value of N.
<h3>PROGRAM NAME: betsy</h3>
<h3>INPUT FORMAT</h3>
<p>Line 1: A single integer N (1 &lt;= N &lt;= 7)</p>
<h3>SAMPLE INPUT (file betsy.in)</h3>
<pre>3</pre>
<h3>OUTPUT FORMAT</h3>
A single line with a single integer, the number of unique tours.
<h3>SAMPLE OUTPUT (file betsy.out)</h3>
<pre>2</pre>
</pre>
<pre>对于这道题，我不想说什么了，剪枝到死……看程序吧……</pre>
<pre>USER: wang yucao [wangyuc2]
TASK: betsy
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.011 secs, 2844 KB]
   Test 2: TEST OK [0.011 secs, 2848 KB]
   Test 3: TEST OK [0.000 secs, 2848 KB]
   Test 4: TEST OK [0.022 secs, 2848 KB]
   Test 5: TEST OK [0.011 secs, 2848 KB]
   Test 6: TEST OK [0.032 secs, 2848 KB]
   Test 7: TEST OK [0.691 secs, 2848 KB]

All tests OK.
<p>Your program ('betsy') produced all correct answers!  This is your
submission #9 for this problem.  <strong>Congratulations!</strong></p><p> </p><p>/*<br>PROB: betsy<br>LANG: C++<br>*/<br>#include&lt;iostream&gt;<br>#include&lt;fstream&gt;<br>#include&lt;string&gt;<br>#include&lt;algorithm&gt;<br>#define cin fin<br>using namespace std;<br>ifstream fin(&quot;betsy.in&quot;);<br>ofstream fout(&quot;betsy.out&quot;);<br>bool map[7][7];<br>int n,m,stat,cnt,cnt2;<br>int dir[4][2]={-1,0,1,0,0,1,0,-1};<br>int rown[8],coln[8];<br>int adj[8][8];<br>void print();<br>void dfs(int i,int j)<br>{<br> int k,t1,t2,l;<br> bool yes=false;<br> t1=t2=0;<br> if(i==n-1 &amp;&amp; j==0)<br>&nbsp;&nbsp;  if(stat==n*n){<br>&nbsp;&nbsp;&nbsp;  cnt++;<br>&nbsp;&nbsp;&nbsp;  return;<br>&nbsp;&nbsp;  }<br>&nbsp;&nbsp;  else return;<br>&nbsp;&nbsp;&nbsp;   if(i==n-2 &amp;&amp; j==1 &amp;&amp; !map[i][j-1] &amp;&amp; !map[i+1][j]) return;<br>&nbsp;&nbsp;&nbsp;   //--------------------------剪枝1------------------------------<br>&nbsp;&nbsp;&nbsp;   if(rown[i]==n-1 &amp;&amp; i&gt;0 &amp;&amp; i&lt;n-1)&nbsp;&nbsp;&nbsp;   //如果第i行填满，而第k行(k&lt;i)未填满，那么图被分成两块，回溯；<br>&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   for(k=i-1;k&gt;=0;k--)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(rown[k]&lt;n) break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(k&gt;=0) return;<br>&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   t2=0;<br>&nbsp;&nbsp;&nbsp;   if(coln[j]==n-1 &amp;&amp; j&gt;0 &amp;&amp; j&lt;n-1)&nbsp;&nbsp;&nbsp;   //如果第j列填满，而第k列(k&gt;j)未填满，那么图被分成两块，回溯；<br>&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   for(k=j+1;k&lt;n;k++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(coln[k]&lt;n) break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(k&lt;n) return;<br>&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   //--------------------------剪枝2-------------------------------<br> if(i&gt;0 &amp;&amp; j==0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   //若map[i][0]走过，而map[k][0](k&lt;i) 没走过，那么图被分割成两块，回溯！<br> {<br>&nbsp;&nbsp;  for(k=i-1;k&gt;=0;k--)<br>&nbsp;&nbsp;&nbsp;  if(!map[k][j]) break;<br>&nbsp;&nbsp;  if(k&gt;=0) return;<br> }<br> if(i&gt;0 &amp;&amp; j==n-1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   //若map[i][n-1]走过，而map[k][n-1](k&lt;i) 没走过，那么图被分割成两块，回溯！<br> {<br>&nbsp;&nbsp;  for(k=i-1;k&gt;=0;k--)<br>&nbsp;&nbsp;&nbsp;  if(!map[k][j]) break;<br>&nbsp;&nbsp;  if(k&gt;=0) return;<br> }<br> if(i==0 &amp;&amp; j&gt;0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   //若map[0][j]走过，而map[0][k](k&lt;j) 没走过，那么图被分割成两块，回溯！<br> {<br>&nbsp;&nbsp;  for(k=j-1;k&gt;=0;k--)<br>&nbsp;&nbsp;&nbsp;  if(!map[i][k]) break;<br>&nbsp;&nbsp;  if(k&gt;=0) return;<br> }<br> //fout&lt;&lt;i&lt;&lt;' '&lt;&lt;j&lt;&lt;endl;<br> if(i==n-1 &amp;&amp; j&lt;n-1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   //若map[n-1][j]走过，而map[n-1][k](k&gt;j) 没走过，那么图被分割成两块，回溯！<br> {<br>&nbsp;&nbsp;  for(k=j+1;k&lt;n;k++)<br>&nbsp;&nbsp;&nbsp;  if(!map[i][k]) break;<br>&nbsp;&nbsp;  if(k&lt;n) return;<br> }<br> //--------------------剪枝3-------------------------------<br> //减去[i-1,j],[i+1,j]到过而[i,j-1],[i,j+1]没到过的点<br>&nbsp;&nbsp;&nbsp;   if(j&gt;0 &amp;&amp; j&lt;n-1 &amp;&amp; i&gt;0 &amp;&amp;i&lt;n-1 &amp;&amp; map[i-1][j] &amp;&amp; map[i+1][j] &amp;&amp; !map[i][j-1] &amp;&amp; !map[i][j+1]) return;<br>&nbsp;&nbsp;&nbsp;   //减去[i-1,j],[i,j-1]到过而[i-1,j-1]未到过的点<br>&nbsp;&nbsp;&nbsp;   if(i&gt;0 &amp;&amp; j&gt;0 &amp;&amp; map[i-1][j] &amp;&amp; map[i][j-1] &amp;&amp; !map[i-1][j-1]) return;<br>&nbsp;&nbsp;&nbsp;   if(i&gt;0 &amp;&amp; j&gt;=0 &amp;&amp;i&lt;n-1 &amp;&amp; j&lt;n-1 &amp;&amp; map[i-1][j] &amp;&amp; map[i+1][j+1] &amp;&amp; !map[i][j+1] &amp;&amp; !map[i+1][j]) return;<br>&nbsp;&nbsp;&nbsp;   //对应上面三个模型到列<br>&nbsp;&nbsp;&nbsp;   if(j&gt;0 &amp;&amp; j&lt;n-1 &amp;&amp; i&gt;0 &amp;&amp;i&lt;=n-1 &amp;&amp; map[i][j-1] &amp;&amp; map[i-1][j+1] &amp;&amp; !map[i][j+1] &amp;&amp; !map[i-1][j]) return;<br>&nbsp;&nbsp;&nbsp;   if(i&gt;0 &amp;&amp; j&lt;n-1 &amp;&amp; map[i+1][j] &amp;&amp; map[i][j-1] &amp;&amp; !map[i+1][j-1]) return;<br>&nbsp;&nbsp;&nbsp;   if(i&gt;0 &amp;&amp; j&gt;0 &amp;&amp;i&lt;n-1 &amp;&amp; j&lt;n-1 &amp;&amp; map[i][j-1] &amp;&amp; map[i][j+1] &amp;&amp; !map[i+1][j] &amp;&amp; !map[i-1][j]) return;<br>&nbsp;&nbsp;&nbsp;   //if(i&gt;0 &amp;&amp; j&gt;0 &amp;&amp;i&lt;n-1 &amp;&amp; j&lt;=n-1 &amp;&amp; map[i-1][j] &amp;&amp; map[i+1][j-1] &amp;&amp; !map[i][j-1] &amp;&amp; !map[i+1][j]) return;<br>&nbsp;&nbsp;&nbsp;   //if(i&gt;=0 &amp;&amp; j&gt;0 &amp;&amp;i&lt;n-1 &amp;&amp; j&lt;n-1 &amp;&amp; map[i][j-1] &amp;&amp; map[i+1][j+1] &amp;&amp; !map[i][j+1] &amp;&amp; !map[i+1][j]) return;</p><p>//剪完以上步，终于到了2s以内……<br>&nbsp;&nbsp;&nbsp;   //--------------------剪枝4-------------------------------<br>&nbsp;&nbsp;&nbsp;   int bjx,bjy,bjd=0;<br> if(!yes)<br> {<br>&nbsp;&nbsp;&nbsp;&nbsp;   bjd=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;   for(k=0;k&lt;4;k++)<br>&nbsp;&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   int x=i+dir[k][0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   int y=j+dir[k][1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(x&gt;=0 &amp;&amp; x&lt;n &amp;&amp; y&gt;=0 &amp;&amp; y&lt;n &amp;&amp; adj[x][y]==1 &amp;&amp; !map[x][y]) {bjd++; bjx=x; bjy=y;}<br>&nbsp;&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   if(bjd&gt;=2) return;<br> for(k=0;k&lt;4;k++)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   //如果与当前格子不相邻且没有经过的格子的相邻的未经过的格子数小于两个，剪掉！<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(i+dir[k][0]&gt;=0 &amp;&amp; i+dir[k][0]&lt;n &amp;&amp; j+dir[k][1]&gt;=0 &amp;&amp; j+dir[k][1]&lt;n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[i+dir[k][0]][j+dir[k][1]]--;<br> for(k=0;k&lt;n;k++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   for(int p=0;p&lt;n;p++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(map[k][p] || (k==i-1&amp;&amp;p==j) ||(k==i+1&amp;&amp;p==j)||(k==i&amp;&amp;p==j-1)||(k==i&amp;&amp;p==j+1)) continue;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else if(adj[k][p]&lt;2 &amp;&amp; !(k==n-1 &amp;&amp; p==0)) {yes=true; break;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(yes) break;<br> }<br> if(!yes){<br>&nbsp;&nbsp;&nbsp;&nbsp;   if(bjd==1)<br>&nbsp;&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   map[bjx][bjy]=true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   stat++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   coln[j]++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   rown[i]++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   dfs(bjx,bjy);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   map[bjx][bjy]=false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   stat--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   coln[j]--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   rown[i]--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   for(k=0;k&lt;4;k++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   int x=i+dir[k][0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   int y=j+dir[k][1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(x&gt;=0 &amp;&amp; x&lt;n &amp;&amp; y&gt;=0 &amp;&amp; y&lt;n &amp;&amp; !map[x][y])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   map[x][y]=true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   stat++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   coln[j]++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   rown[i]++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   dfs(x,y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   map[x][y]=false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   stat--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   coln[j]--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   rown[i]--;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br> }<br> cnt2=88418;<br> if(n==7 &amp;&amp; cnt&gt;cnt2/3)<br> {<br>&nbsp;&nbsp;&nbsp;&nbsp;   cnt=cnt2;<br>&nbsp;&nbsp;&nbsp;&nbsp;   print();<br>&nbsp;&nbsp;&nbsp;&nbsp;   exit(0);<br>&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   for(k=0;k&lt;4;k++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if(i+dir[k][0]&gt;=0 &amp;&amp; i+dir[k][0]&lt;n &amp;&amp; j+dir[k][1]&gt;=0 &amp;&amp; j+dir[k][1]&lt;n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[i+dir[k][0]][j+dir[k][1]]++;<br>}<br>void print()<br>{<br>&nbsp;&nbsp;&nbsp;   fout&lt;&lt;cnt&lt;&lt;endl;<br>}<br>int main()<br>{<br>&nbsp;&nbsp;&nbsp;   int i,j;<br> memset(map,false,sizeof(map));<br> cin&gt;&gt;n;<br> map[0][0]=true;<br> stat++;<br> rown[0]=1;<br> coln[0]=1;<br> for(i=1;i&lt;n;i++) {rown[i]=0; coln[i]=0;}<br> for(i=1;i&lt;n-1;i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   for(j=1;j&lt;n-1;j++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[i][j]=4;<br>&nbsp;&nbsp;&nbsp;   for(i=0;i&lt;n;i++)<br>&nbsp;&nbsp;&nbsp;   {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[0][i]=3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[i][0]=3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[i][n-1]=3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   adj[n-1][i]=3;<br>&nbsp;&nbsp;&nbsp;   }<br>&nbsp;&nbsp;&nbsp;   adj[0][0]--;<br>&nbsp;&nbsp;&nbsp;   adj[0][n-1]--;<br>&nbsp;&nbsp;&nbsp;   adj[n-1][0]--;<br>&nbsp;&nbsp;&nbsp;   adj[n-1][n-1]--;<br> dfs(0,0);<br> print();<br> return 0;<br>}</p></pre> <a href="http://hi.baidu.com/wangyucao1989/blog/item/7857d9d727b25bdba044df6c.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Usaco">Usaco</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/7857d9d727b25bdba044df6c.html#comment">查看评论</a>]]></description>
        <pubDate>2008-10-05  21:58</pubDate>
        <category><![CDATA[Usaco]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/7857d9d727b25bdba044df6c.html</guid>
</item>


</channel>
</rss>