﻿<?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++博客-kernel</title><link>http://www.cppblog.com/kernel/</link><description>kernel</description><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:06:13 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:06:13 GMT</pubDate><ttl>60</ttl><item><title>acm比赛注意事项</title><link>http://www.cppblog.com/kernel/archive/2014/02/23/205912.html</link><dc:creator>oskernel</dc:creator><author>oskernel</author><pubDate>Sun, 23 Feb 2014 06:35:00 GMT</pubDate><guid>http://www.cppblog.com/kernel/archive/2014/02/23/205912.html</guid><wfw:comment>http://www.cppblog.com/kernel/comments/205912.html</wfw:comment><comments>http://www.cppblog.com/kernel/archive/2014/02/23/205912.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/kernel/comments/commentRss/205912.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kernel/services/trackbacks/205912.html</trackback:ping><description><![CDATA[<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>1.</strong>服务器不支持long double类型，最高支持到double（浮点型）和long long（长整型），注意 double 比float 更适宜。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>2.</strong>while语句中的(<strong>cin&gt;&gt;M&gt;&gt;N &amp;&amp; M!=0 &amp;&amp; N!=0</strong>)（注意是<strong>与</strong>还是<strong>或</strong>）上式也可改写成<strong>(cin&gt;&gt;M&gt;&gt;N &amp;&amp; (M || N))</strong></span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>3.</strong>在有些题目，特别是数据比较烦的时候，或者数据精度要求高的时候，可能精度要求不够。。。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>4.</strong>（引用其他人的）奇怪的事情多着呢.昨天我做2305时候,m=1; for(i=1; i&lt;=k; i++) m *= 2和 m = (1&lt;&lt;k);本来是一样的.但是前面提交就AC,后面一个就一直的WA。<strong>（以上为原文，不过我觉得左移和乘2是有所不同的，乘2符号位不会变，但是，左移式连同符号位一起左移，空位补零，那正数左移后就可能变成负数了）。</strong></span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>5.</strong>&amp;可表示取地址符，也可以表示为对某个变量的引用。注意函数是传值，还是传地址的。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>6.</strong>abs的参数是整型，而不是浮点型。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>7.</strong>有些题目看上去好象用什么经典的算法，但如果你把题目看清楚，也许会有更简单的算法或者完全不同的思路，我刚开始就把他当作dp去做，可后来发现简单的循环就可以了。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>8.</strong></span><span style="font-family: 'Microsoft YaHei'; font-size: 14px">关于cin和getline，cin后面不读入回车符，导致在输入流中还保存有，在下次读入getline的时候，getline就读入的是回车符，而不是我门要读的东西。1925考虑的就是这点。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>9.</strong>当用cin TLE的时候试试scanf</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>10.</strong>当发现一个题目里面出现的数据跟16有关时,想想是否可以通过位运算解决(1219,1639)</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>11.</strong>一定要注意结果是否会是long long类型</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>12.输入是一整行的字符串。<br /></strong>如1392<br />如果你用chara[ 200 ]来保存，<br />cin.getline( a, 200 );<span class="Apple-converted-space">&nbsp;</span><br />如果你用stringstr;来保存的：<br />Code:<span class="Apple-converted-space">&nbsp;</span><br />getline( cin , str );</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>13.一个InputBlock对应一个OutputBlock，OutputBlock之间有空行。<br /></strong>如1152<br />int Case = 0;<span class="Apple-converted-space">&nbsp;</span><br />{<span class="Apple-converted-space">&nbsp;</span><br />&nbsp;&nbsp;&nbsp; if ( Case++ ) cout &lt;&lt; endl;<span class="Apple-converted-space">&nbsp;</span><br />&nbsp;&nbsp;&nbsp; ...<span class="Apple-converted-space">&nbsp;</span><br />&nbsp;&nbsp;&nbsp; cout &lt;&lt; x &lt;&lt; endl;<span class="Apple-converted-space">&nbsp;</span><br />}</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>14.一个一行中输入不定个数字的输入处理方法:<br /></strong>&nbsp;&nbsp;&nbsp; charinput[501];<br />&nbsp;&nbsp;&nbsp; int blankCount;<br />&nbsp;&nbsp;&nbsp; int blankPos[501];<br />&nbsp;&nbsp;&nbsp; int i, j, s;<br /><br />&nbsp;&nbsp;&nbsp; cin.getline(input, 500);<br />&nbsp;&nbsp;&nbsp; blankCount = 0;<br />&nbsp;&nbsp;&nbsp; blankPos[0] = 0;<br />&nbsp;&nbsp;&nbsp; j = strlen(input);<br />&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; j; ++ i)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (input[i] == ' ')<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<span class="Apple-converted-space">&nbsp;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blankCount ++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blankPos[blankCount] = i;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp; for (i = 0; i &lt;= blankCount; ++ i)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sscanf(input + blankPos[i],"%d", &amp;s);<span class="Apple-converted-space">&nbsp;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%d\n", s);<br />&nbsp;&nbsp; &nbsp;}</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>15.题目中描述：&#8220;Anegative value for n indicates the end of input. &#8221;</strong><br />Sample Input<br />1<br />2<br />3<br />-1<br />如果在读题目的时候不注意，而根据sampleinput作判断，输入的时候用：<br />while(cin&gt;&gt;n &amp;&amp; n!=-1)<br />{ ... }<br />则会出错，而应该<br />while(cin&gt;&gt;n &amp;&amp; n &gt; 0)<br />{ ... }<br /><br />这是在zoj_1475中的一个陷阱。</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>16.打开文件的语句别写错了,还有文件名小心郁闷死你.多注意点细节,不要频繁提交。</strong></span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>17.</strong>一些常用的词汇(如max,min)作为变量名在本地机上可以正常编译,但递交上去不一定能编译.更郁闷的是用了一些常用的词汇,编译也通过了,输出答案也是正确的,但就是wa.解决方案:单词前面加上一个字母,比如lmax,lmin</span></p>
<p style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 14px"><strong>18.</strong>当提交<strong>一直</strong>WA时,再仔细读一边题目,而不是一味的想特殊数据。</span></p><img src ="http://www.cppblog.com/kernel/aggbug/205912.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kernel/" target="_blank">oskernel</a> 2014-02-23 14:35 <a href="http://www.cppblog.com/kernel/archive/2014/02/23/205912.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>string对象小结</title><link>http://www.cppblog.com/kernel/archive/2013/12/06/204622.html</link><dc:creator>oskernel</dc:creator><author>oskernel</author><pubDate>Fri, 06 Dec 2013 05:07:00 GMT</pubDate><guid>http://www.cppblog.com/kernel/archive/2013/12/06/204622.html</guid><wfw:comment>http://www.cppblog.com/kernel/comments/204622.html</wfw:comment><comments>http://www.cppblog.com/kernel/archive/2013/12/06/204622.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/kernel/comments/commentRss/204622.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/kernel/services/trackbacks/204622.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/kernel/archive/2013/12/06/204622.html'>阅读全文</a><img src ="http://www.cppblog.com/kernel/aggbug/204622.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/kernel/" target="_blank">oskernel</a> 2013-12-06 13:07 <a href="http://www.cppblog.com/kernel/archive/2013/12/06/204622.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>