﻿<?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++博客-firstnode</title><link>http://www.cppblog.com/firstnode/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 23 Apr 2026 10:06:50 GMT</lastBuildDate><pubDate>Thu, 23 Apr 2026 10:06:50 GMT</pubDate><ttl>60</ttl><item><title>POJ 3126  学会广搜队列的用法</title><link>http://www.cppblog.com/firstnode/archive/2009/03/08/75883.html</link><dc:creator>生活要低调</dc:creator><author>生活要低调</author><pubDate>Sun, 08 Mar 2009 03:23:00 GMT</pubDate><guid>http://www.cppblog.com/firstnode/archive/2009/03/08/75883.html</guid><wfw:comment>http://www.cppblog.com/firstnode/comments/75883.html</wfw:comment><comments>http://www.cppblog.com/firstnode/archive/2009/03/08/75883.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/firstnode/comments/commentRss/75883.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/firstnode/services/trackbacks/75883.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 第N道的广搜,这几天就准备做广搜了...真的需要好好练习下...Prime Path                        Time Limit: 1000MS                        Memory Limit: 65536K                            Total Submissions: 187...&nbsp;&nbsp;<a href='http://www.cppblog.com/firstnode/archive/2009/03/08/75883.html'>阅读全文</a><img src ="http://www.cppblog.com/firstnode/aggbug/75883.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/firstnode/" target="_blank">生活要低调</a> 2009-03-08 11:23 <a href="http://www.cppblog.com/firstnode/archive/2009/03/08/75883.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 3278 (第一道队列题,爽)</title><link>http://www.cppblog.com/firstnode/archive/2009/03/07/75839.html</link><dc:creator>生活要低调</dc:creator><author>生活要低调</author><pubDate>Sat, 07 Mar 2009 10:33:00 GMT</pubDate><guid>http://www.cppblog.com/firstnode/archive/2009/03/07/75839.html</guid><wfw:comment>http://www.cppblog.com/firstnode/comments/75839.html</wfw:comment><comments>http://www.cppblog.com/firstnode/archive/2009/03/07/75839.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/firstnode/comments/commentRss/75839.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/firstnode/services/trackbacks/75839.html</trackback:ping><description><![CDATA[<div class=ptt lang=en-US>学会了队列.这道题的主要思想:<br><br>5先入列&nbsp;&nbsp; 把5出列&nbsp; 5&nbsp;可以变成 4 ,6 , 10, ,把得到的数入列,然后再出列分别处理..如果前面出现过就不入列..定义一个计数数组,然后number[y - 1] = number[y] + 1;&nbsp; number[y + 1] = number[y] + 1; number[y * 2] = number[y] + 1;<br><br>Catch That Cow</div>
<div class=plm>
<table align=center>
    <tbody>
        <tr>
            <td><strong>Time Limit:</strong> 2000MS</td>
            <td width=10></td>
            <td><strong>Memory Limit:</strong> 65536K</td>
        </tr>
        <tr>
            <td><strong>Total Submissions:</strong> 8341</td>
            <td width=10></td>
            <td><strong>Accepted:</strong> 2476</td>
        </tr>
    </tbody>
</table>
</div>
<p class=pst>Description</p>
<div class=ptx lang=en-US>
<p>Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point <em>N</em> (0 &#8804; <em>N</em> &#8804; 100,000) on a number line and the cow is at a point <em>K</em> (0 &#8804; <em>K</em> &#8804; 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting.</p>
<p>* Walking: FJ can move from any point <em>X</em> to the points <em>X </em>- 1 or <em>X </em>+ 1 in a single minute<br>* Teleporting: FJ can move from any point <em>X</em> to the point 2 &#215; <em>X</em> in a single minute.</p>
<p>If the cow, unaware of its pursuit, does not move at all, how long does it take for Farmer John to retrieve it?</p>
</div>
<p class=pst>Input</p>
<div class=ptx lang=en-US>Line 1: Two space-separated integers: <em>N</em> and <em>K</em></div>
<p class=pst>Output</p>
<div class=ptx lang=en-US>Line 1: The least amount of time, in minutes, it takes for Farmer John to catch the fugitive cow.</div>
<p class=pst>Sample Input</p>
<pre class=sio>5 17</pre>
<p class=pst>Sample Output</p>
<pre class=sio>4</pre>
<p class=pst>Hint</p>
<div class=ptx lang=en-US>The fastest way for Farmer John to reach the fugitive cow is to move along the following path: 5-10-9-18-17, which takes 4 minutes.<br><br><br><br><br>
<p align=center><font color=#333399 size=4>Source Code</font></p>
<table style="FONT-SIZE: 10pt" align=center>
    <tbody>
        <tr>
            <td><strong>Problem:</strong> <a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=3278"><u><font color=#810081>3278</font></u></a></td>
            <td width=10><u><font color=#810081></font></u></td>
            <td><strong>User:</strong> <a href="http://acm.pku.edu.cn/JudgeOnline/userstatus?user_id=luoguangyao"><u><font color=#810081>luoguangyao</font></u></a></td>
        </tr>
        <tr>
            <td><strong>Memory:</strong> 1048K</td>
            <td width=10></td>
            <td><strong>Time:</strong> 110MS</td>
        </tr>
        <tr>
            <td><strong>Language:</strong> C++</td>
            <td width=10></td>
            <td><strong>Result:</strong> <font color=blue>Accepted</font></td>
        </tr>
    </tbody>
</table>
<ul>
    <li><font color=#333399 size=5>Source Code</font>
    <pre class="sh_cpp sh_sourceCode" style="FONT-FAMILY: Courier New,Courier,monospace"><span class=sh_preproc>#include</span> <span class=sh_string>&lt;iostream&gt;</span>
    <span class=sh_preproc>#include</span> <span class=sh_string>&lt;queue&gt;</span>
    <span class=sh_keyword>using</span> <span class=sh_keyword>namespace</span><span class=sh_symbol>::</span>std<span class=sh_symbol>;</span>
    <span class=sh_type>int</span> number<span class=sh_symbol>[</span><span class=sh_number>100001</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_cbracket>{</span><span class=sh_number>0</span><span class=sh_cbracket>}</span><span class=sh_symbol>;</span>
    <span class=sh_type>bool</span> num<span class=sh_symbol>[</span><span class=sh_number>100001</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_cbracket>{</span><span class=sh_number>0</span><span class=sh_cbracket>}</span><span class=sh_symbol>;</span>
    <span class=sh_type>int</span> <span class=sh_function>main</span><span class=sh_symbol>()</span>
    <span class=sh_cbracket>{</span>
    queue<span class=sh_symbol>&lt;</span><span class=sh_type>int</span><span class=sh_symbol>&gt;</span> x<span class=sh_symbol>;</span>
    <span class=sh_type>int</span> a<span class=sh_symbol>;</span>
    <span class=sh_type>int</span> b<span class=sh_symbol>;</span>
    <span class=sh_function>scanf</span><span class=sh_symbol>(</span><span class=sh_string>"%d%d"</span><span class=sh_symbol>,&amp;</span>a<span class=sh_symbol>,&amp;</span>b<span class=sh_symbol>);</span>
    <span class=sh_type>int</span> count <span class=sh_symbol>=</span> <span class=sh_number>0</span><span class=sh_symbol>;</span>
    number<span class=sh_symbol>[</span>a<span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_number>0</span><span class=sh_symbol>;</span>
    x<span class=sh_symbol>.</span><span class=sh_function>push</span><span class=sh_symbol>(</span>a<span class=sh_symbol>);</span>
    <span class=sh_keyword>while</span> <span class=sh_symbol>(</span>x<span class=sh_symbol>.</span><span class=sh_function>size</span><span class=sh_symbol>())</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_type>int</span> y <span class=sh_symbol>=</span> x<span class=sh_symbol>.</span><span class=sh_function>front</span><span class=sh_symbol>();</span>
    x<span class=sh_symbol>.</span><span class=sh_function>pop</span><span class=sh_symbol>();</span>
    num<span class=sh_symbol>[</span>y<span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(</span>y <span class=sh_symbol>==</span> b<span class=sh_symbol>)</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_keyword>break</span><span class=sh_symbol>;</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_keyword>else</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(</span>y <span class=sh_symbol>-</span> <span class=sh_number>1</span> <span class=sh_symbol>&gt;=</span> <span class=sh_number>0</span><span class=sh_symbol>)</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(!</span>num<span class=sh_symbol>[</span>y <span class=sh_symbol>-</span> <span class=sh_number>1</span><span class=sh_symbol>])</span>
    <span class=sh_cbracket>{</span>
    x<span class=sh_symbol>.</span><span class=sh_function>push</span><span class=sh_symbol>(</span>y <span class=sh_symbol>-</span> <span class=sh_number>1</span><span class=sh_symbol>);</span>
    number<span class=sh_symbol>[</span>y <span class=sh_symbol>-</span> <span class=sh_number>1</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> number<span class=sh_symbol>[</span>y<span class=sh_symbol>]</span> <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    num<span class=sh_symbol>[</span>y <span class=sh_symbol>-</span> <span class=sh_number>1</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(</span>y <span class=sh_symbol>+</span> <span class=sh_number>1</span> <span class=sh_symbol>&lt;=</span> <span class=sh_number>100000</span><span class=sh_symbol>)</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(!</span>num<span class=sh_symbol>[</span>y <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>])</span>
    <span class=sh_cbracket>{</span>
    x<span class=sh_symbol>.</span><span class=sh_function>push</span><span class=sh_symbol>(</span>y <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>);</span>
    number<span class=sh_symbol>[</span>y <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> number<span class=sh_symbol>[</span>y<span class=sh_symbol>]</span> <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    num<span class=sh_symbol>[</span>y <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(</span>y <span class=sh_symbol>*</span> <span class=sh_number>2</span> <span class=sh_symbol>&lt;=</span> <span class=sh_number>100000</span><span class=sh_symbol>)</span>
    <span class=sh_cbracket>{</span>
    <span class=sh_keyword>if</span> <span class=sh_symbol>(!</span>num<span class=sh_symbol>[</span>y <span class=sh_symbol>*</span> <span class=sh_number>2</span><span class=sh_symbol>])</span>
    <span class=sh_cbracket>{</span>
    x<span class=sh_symbol>.</span><span class=sh_function>push</span><span class=sh_symbol>(</span>y <span class=sh_symbol>*</span> <span class=sh_number>2</span><span class=sh_symbol>);</span>
    number<span class=sh_symbol>[</span>y <span class=sh_symbol>*</span> <span class=sh_number>2</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> number<span class=sh_symbol>[</span>y<span class=sh_symbol>]</span> <span class=sh_symbol>+</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    num<span class=sh_symbol>[</span>y <span class=sh_symbol>*</span> <span class=sh_number>2</span><span class=sh_symbol>]</span> <span class=sh_symbol>=</span> <span class=sh_number>1</span><span class=sh_symbol>;</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_cbracket>}</span>
    <span class=sh_cbracket>}</span>
    cout <span class=sh_symbol>&lt;&lt;</span> number<span class=sh_symbol>[</span>b<span class=sh_symbol>]</span> <span class=sh_symbol>&lt;&lt;</span> endl<span class=sh_symbol>;</span>
    <span class=sh_keyword>return</span> <span class=sh_number>0</span><span class=sh_symbol>;</span>
    <span class=sh_cbracket>}</span></pre>
    </li>
</ul>
</div>
<img src ="http://www.cppblog.com/firstnode/aggbug/75839.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/firstnode/" target="_blank">生活要低调</a> 2009-03-07 18:33 <a href="http://www.cppblog.com/firstnode/archive/2009/03/07/75839.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 2157 </title><link>http://www.cppblog.com/firstnode/archive/2009/03/07/75825.html</link><dc:creator>生活要低调</dc:creator><author>生活要低调</author><pubDate>Sat, 07 Mar 2009 07:14:00 GMT</pubDate><guid>http://www.cppblog.com/firstnode/archive/2009/03/07/75825.html</guid><wfw:comment>http://www.cppblog.com/firstnode/comments/75825.html</wfw:comment><comments>http://www.cppblog.com/firstnode/archive/2009/03/07/75825.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/firstnode/comments/commentRss/75825.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/firstnode/services/trackbacks/75825.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 这题没把我弄疯了.一个小时写完,改了2个小时...题目给的数据太弱了,需要自己写一些数据来验证...在这里给大家提供些数据题目Maze                        Time Limit: 2000MS                        Memory Limit: 65536K                         ...&nbsp;&nbsp;<a href='http://www.cppblog.com/firstnode/archive/2009/03/07/75825.html'>阅读全文</a><img src ="http://www.cppblog.com/firstnode/aggbug/75825.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/firstnode/" target="_blank">生活要低调</a> 2009-03-07 15:14 <a href="http://www.cppblog.com/firstnode/archive/2009/03/07/75825.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>