﻿<?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++博客-Be Brave-文章分类-POJ</title><link>http://www.cppblog.com/tiantiantian/category/16327.html</link><description>++U ! fight&amp;enjoy!</description><language>zh-cn</language><lastBuildDate>Wed, 06 Apr 2011 06:54:46 GMT</lastBuildDate><pubDate>Wed, 06 Apr 2011 06:54:46 GMT</pubDate><ttl>60</ttl><item><title>POJ2288</title><link>http://www.cppblog.com/tiantiantian/articles/143366.html</link><dc:creator>sweet empyrean</dc:creator><author>sweet empyrean</author><pubDate>Sun, 03 Apr 2011 13:31:00 GMT</pubDate><guid>http://www.cppblog.com/tiantiantian/articles/143366.html</guid><wfw:comment>http://www.cppblog.com/tiantiantian/comments/143366.html</wfw:comment><comments>http://www.cppblog.com/tiantiantian/articles/143366.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/tiantiantian/comments/commentRss/143366.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/tiantiantian/services/trackbacks/143366.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;1#include&nbsp;&lt;iostream&gt;&nbsp;2using&nbsp;namespace&nbsp;std;&nbsp;3&nbsp;4&nbsp;5const&nbsp;int&nbsp;inf&nbsp;=&nbsp;1&lt;&lt;14;&nbsp;6int&nbsp;n,&nbsp;ma;&nbsp;7__int64&nbsp;dp[inf][14...&nbsp;&nbsp;<a href='http://www.cppblog.com/tiantiantian/articles/143366.html'>阅读全文</a><img src ="http://www.cppblog.com/tiantiantian/aggbug/143366.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/tiantiantian/" target="_blank">sweet empyrean</a> 2011-04-03 21:31 <a href="http://www.cppblog.com/tiantiantian/articles/143366.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ1141</title><link>http://www.cppblog.com/tiantiantian/articles/142256.html</link><dc:creator>sweet empyrean</dc:creator><author>sweet empyrean</author><pubDate>Sun, 20 Mar 2011 02:54:00 GMT</pubDate><guid>http://www.cppblog.com/tiantiantian/articles/142256.html</guid><wfw:comment>http://www.cppblog.com/tiantiantian/comments/142256.html</wfw:comment><comments>http://www.cppblog.com/tiantiantian/articles/142256.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/tiantiantian/comments/commentRss/142256.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/tiantiantian/services/trackbacks/142256.html</trackback:ping><description><![CDATA[

POJ1141<div><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">#include </span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">iostream</span><span style="color: rgb(0, 0, 0); ">&gt;</span><span style="color: rgb(0, 0, 0); ">

</span><span style="color: rgb(0, 0, 255); ">using</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">namespace</span><span style="color: rgb(0, 0, 0); "> std;
</span><span style="color: rgb(0, 0, 255); ">const</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> MAXN </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">110</span><span style="color: rgb(0, 0, 0); ">;
</span><span style="color: rgb(0, 0, 255); ">char</span><span style="color: rgb(0, 0, 0); "> str[MAXN] ;
</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> dp [MAXN][MAXN];
</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> path[MAXN][MAXN];

</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> output( </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> i, </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> j){
   <span style="COLOR:red"> if(i&gt;j)
        return 0 </span></span><span style="color: rgb(0, 0, 0); ">;
    </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(i</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">j){
        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">||</span><span style="color: rgb(0, 0, 0); ">str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)
            cout</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">;
        </span><span style="color: rgb(0, 0, 255); ">else</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">[</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">||</span><span style="color: rgb(0, 0, 0); ">str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">]</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)
            cout</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">[</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">]</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">;
        </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
    }

    </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(path[i][j]</span><span style="color: rgb(0, 0, 0); ">==-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">){
        cout</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">str[i];
        output(i</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">, j</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">);
        cout</span><span style="color: rgb(0, 0, 0); ">&lt;&lt;</span><span style="color: rgb(0, 0, 0); ">str[j];
    }
    </span><span style="color: rgb(0, 0, 255); ">else</span><span style="color: rgb(0, 0, 0); "> {

        output(i, path[i][j]);
        output(path[i][j]</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">, j);
    }
    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
}
</span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> main() {

    </span><span style="color: rgb(0, 0, 255); ">int</span><span style="color: rgb(0, 0, 0); "> n, len, i, j,k,r;
    </span><span style="color: rgb(0, 0, 255); ">while</span><span style="color: rgb(0, 0, 0); ">(gets(str)){                      
        n </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> strlen(str);                  
        </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(n</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">){
            printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
            </span><span style="color: rgb(0, 0, 255); ">continue</span><span style="color: rgb(0, 0, 0); ">;
        }
       <span style="BACKGROUND-COLOR:yellow"> memset(dp,0,sizeof(dp));           

</span></span><span style="color: rgb(0, 0, 0); ">
        </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">( i </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">n;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
            dp[i][i] </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">;
        }

        <span style="COLOR:red">for( len = 1;len&lt; n;len++){
        </span></span><span style="color: rgb(0, 0, 0); ">    </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">( i </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">; i</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">n</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">len;i</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
                j </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> i</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">len;
               <span style="COLOR:red"> dp[i][j]=INT_MAX;
               </span></span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">((str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">(</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[j]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)</span><span style="color: rgb(0, 0, 0); ">||</span><span style="color: rgb(0, 0, 0); ">(str[i]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">[</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span><span style="color: rgb(0, 0, 0); ">str[j]</span><span style="color: rgb(0, 0, 0); ">==</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">]</span><span style="color: rgb(0, 0, 0); ">'</span><span style="color: rgb(0, 0, 0); ">)){
                    </span><span style="BACKGROUND-COLOR:yellow">if(dp[i][j]&gt;dp[i+1][j-1]){</span><span style="color: rgb(0, 0, 0); ">&nbsp;</span></span></div><div><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "><span class="Apple-tab-span" style="white-space:pre">		</span>        dp[i][j] </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> dp[i</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">][j</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">];  
                        path[i][j] </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">;
                    }
                }

                </span><span style="color: rgb(0, 0, 255); ">for</span><span style="color: rgb(0, 0, 0); ">( k </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> i;k</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">j;k</span><span style="color: rgb(0, 0, 0); ">++</span><span style="color: rgb(0, 0, 0); ">){
                    </span><span style="color: rgb(0, 0, 255); ">if</span><span style="color: rgb(0, 0, 0); ">(dp[i][k]</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">dp[k</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">][j]</span><span style="color: rgb(0, 0, 0); ">&lt;</span><span style="color: rgb(0, 0, 0); ">dp[i][j]){
                        dp[i][j] </span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> dp[i][k]</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">dp[k</span><span style="color: rgb(0, 0, 0); ">+</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">][j];
                        path[i][j]</span><span style="color: rgb(0, 0, 0); ">=</span><span style="color: rgb(0, 0, 0); "> k;
                    }
                }
            }
        }
        output( </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">, n</span><span style="color: rgb(0, 0, 0); ">-</span><span style="color: rgb(0, 0, 0); ">1</span><span style="color: rgb(0, 0, 0); ">);
        printf(</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">\\n</span><span style="color: rgb(0, 0, 0); ">"</span><span style="color: rgb(0, 0, 0); ">);
    }
    </span><span style="color: rgb(0, 0, 255); ">return</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(0, 0, 0); ">0</span><span style="color: rgb(0, 0, 0); ">;
}</span></span></div><div><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "><span style="font-family: verdana, arial, helvetica, sans-serif; white-space: normal; font-size: 12px; border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">char * gets ( char * str );</pre><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: verdana, arial, helvetica, sans-serif; white-space: normal; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">size_t strlen ( const char * str );</pre><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: verdana, arial, helvetica, sans-serif; white-space: normal; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">void * memset ( void * ptr, int value, size_t num );&nbsp;</pre><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">//<span style="font-family: verdana, arial, helvetica, sans-serif; white-space: normal; ">Sets the first&nbsp;<em>num</em>&nbsp;bytes of the block of memory pointed by&nbsp;<em>ptr</em>&nbsp;to the specified&nbsp;<em>value</em>&nbsp;(interpreted as an<tt><span style="COLOR:red">&nbsp;unsigned char</span></tt>)</span></pre><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br></pre></span></pre></span></pre></span></span></span></div><img src ="http://www.cppblog.com/tiantiantian/aggbug/142256.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/tiantiantian/" target="_blank">sweet empyrean</a> 2011-03-20 10:54 <a href="http://www.cppblog.com/tiantiantian/articles/142256.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>