<?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[关于Hadoop-0.20.203.0通过Eclipse连接编程的问题]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/279cef87c4b37c34c75cc315.html]]></link>
        <description><![CDATA[
		
		<p>对于Hadoop开发者来讲，通过JAVA API编程是进入Map-Reduce分布式开发的第一步。由于Eclipse本身并没有提供对MapReduce编程模式的支持，所以需要一些简单的步骤来实现。</p><p>1. 安装Hadoop。</p><p>本文的Hadoop是部署在虚拟机上的伪分布模式。相关软件环境如下：</p><p>JDK： sun jdk1.6.0_30</p><p>Hadoop:&nbsp; hadoop-0.20.203.0</p><p>Linux:&nbsp; Ubuntu 11.10</p><p>Eclipse:&nbsp; Eclipse Indigo 3.7.1</p><p>关于Hadoop伪分布环境的具体配置方式，此处不再赘述。设置方面，core-site.xml中fs.default.name中填写的是hdfs://localhost:9000</p><p>&nbsp;</p><p>2. 设置环境</p><p>在终端中输入</p><p>$ sudo vim /etc/profile</p><p>修改运行环境，在文件最尾添加如下内容：</p><p>export HADOOP_HOME=/home/wangyucao/hadoop-0.20.203.0 (此处即为hadoop的安装目录)<br />export PATH=$PATH:#HADOOP_HOME/bin</p><p>&nbsp;</p><p>3. 安装Eclipse</p><p>在Ubuntu软件中心搜索Eclipse进行安装，或者通过官网下载Eclipse归档文件。此处选择通过官网下载，得到：</p><p>eclipse-jee-indigo-SR1-linux-gtk.tar.gz&nbsp;</p><p>解压该文件，并放在/usr目录下：</p><p>$ tar -zxvf eclipse-jee-indigo-SR1-linux-gtk.tar.gz&nbsp;</p><p>$ sudo mv eclipse /usr/</p><p>完成安装步骤。</p><p>&nbsp;</p><p>4. 安装hadoop-eclipse插件</p><p>hadoop的发行版本中都包含了hadoop-eclipse-plugin插件。在开发hadoop应用时，需要首先安装该Eclipse插件。</p><p>看到网上的教程，一般都是说直接将HADOOP_HOME/lib中的 hadoop-eclipse-plugin-0.20.203.0.jar 复制到eclipse安装目录下的plugins目录中。<span style="color: #ff0000;">但是在我实践尝试中，发现hadoop-0.20.203.0版本的该包如果直接复制到eclipse的插件目录中，在连接DFS时会出现错误，提示信息为： &quot;error: failure to login&quot;,弹出的错误提示框内容为&quot;An internal error occurred during: &quot;Connecting to DFS hadoop&quot;. org/apache/commons/configuration/Configuration&quot;. 经过察看Eclipse的log，发现是缺少jar包导致的。进一步查找资料后，发现直接复制hadoop-eclipse-plugin-0.20.203.0.jar，该包中lib目录下缺少了jar包。</span></p><p>经过网上资料搜集，此处给出正确的安装方法：</p><p>首先要对hadoop-eclipse-plugin-0.20.203.0.jar进行修改。用归档管理器打开该包，发现只有commons-cli-1.2.jar 和hadoop-core.jar两个包。将HADOOP_HOME/lib目录下的 commons-configuration-1.6.jar , commons-httpclient-3.0.1.jar , commons-lang-2.4.jar , jackson-core-asl-1.0.1.jar 和 jackson-mapper-asl-1.0.1.jar 等5个包复制到hadoop-eclipse-plugin-0.20.203.0.jar的lib目录下，如下图：</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/6da0eec79f3df8dce37a25dacd11728b461028a1.jpg" /></span></p><p>然后，修改该包META-INF目录下的MANIFEST.MF，将classpath修改为一下内容：</p><p>Bundle-ClassPath: classes/,lib/hadoop-core.jar,lib/commons-cli-1.2.jar,lib/commons-httpclient-3.0.1.jar,lib/jackson-core-asl-1.0.1.jar,lib/jackson-mapper-asl-1.0.1.jar,lib/commons-configuration-1.6.jar,lib/commons-lang-2.4.jar</p><p>如下图：</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/9a2b3ef81a4c510f648548516059252dd52aa5ac.jpg" /></span></p><p>这样就完成了对hadoop-eclipse-plugin-0.20.203.0.jar的修改。</p><p>最后，将hadoop-eclipse-plugin-0.20.203.0.jar复制到Eclipse的plugins目录下：</p><p>$ cd ~/hadoop-0.20.203.0/lib</p><p>$ sudo cp hadoop-eclipse-plugin-0.20.203.0.jar /usr/eclipse/plugins/</p><p>&nbsp;</p><p>5. 在Eclipse中对该插件进行配置。</p><p>首先，打开Eclipse，设置好workspace。</p><p>选择window -&gt; open perspective -&gt; Other... ， 选择有大象图标的 Map/Reduce.</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/9d65ccd8bc3eb1352d731df0a61ea8d3fc1f44b0.jpg" /></span></p><p>此时，就打开了Map/Reduce的开发环境。可以看到，右下角多了一个Map/Reduce Locations的框。如下图：</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/b9609efbfbedab6467cee78bf736afc378311ea8.jpg" height="652" width="866" /></span></p><p>然后，设置Hadoop的环境参数。选择Map/Reduce Locations 标签，点击该标签最右边的大象图标，即那个齿轮状图标右侧的大象图标，打开参数设置页面，参数填写如下图：</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/1e20adf0f736afc311bc952eb319ebc4b64512bc.jpg" /></span></p><p>Location Name ： 此处为参数设置名称，可以任意填写</p><p>Map/Reduce Master (此处为Hadoop集群的Map/Reduce地址，应该和mapred-site.xml中的mapred.job.tracker设置相同)</p><p>&nbsp;&nbsp;&nbsp; Host: localhost</p><p>&nbsp;&nbsp;&nbsp; port: 9001</p><p>DFS Master&nbsp; (此处为Hadoop的master服务器地址，应该和core-site.xml中的 fs.default.name 设置相同)</p><p>&nbsp;&nbsp;&nbsp; Host: localhost</p><p>&nbsp;&nbsp;&nbsp; Port: 9000</p><p>设置完成后，点击Finish就应用了该设置。</p><p>此时，在最左边的Project Explorer中就能看到DFS的目录，如下图所示。</p><p><span><img small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/ed70ef292df5e0fe91a0234a5c6034a85fdf72b4.jpg" height="655" width="870" /></span></p><p>到这里，就完成了hadoop插件的设置过程。</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/279cef87c4b37c34c75cc315.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/%D4%C6%BC%C6%CB%E3%26%2347%3Bhadoop">云计算&#47;hadoop</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/279cef87c4b37c34c75cc315.html#comment">查看评论</a>]]></description>
        <pubDate>2011-12-18  16:48</pubDate>
        <category><![CDATA[云计算&#47;hadoop]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/279cef87c4b37c34c75cc315.html</guid>
</item>

<item>
        <title><![CDATA[各种穷……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/119be4ad870849124a36d616.html]]></link>
        <description><![CDATA[
		
		<p>各种穷……</p><p>奖学金还没定下来，没钱……</p><p>腾讯奖金和报销车票还没发下来，没钱……</p><p>但是，还要报驾校，尼玛快三千啊~</p><p>又快要交住宿费了，尼玛一千啊……</p><p>三张银行卡，余额加起来只有八百啊……</p><p>总之，各种穷……</p><p><img src="http://img.baidu.com/hi/jx2/j_0013.gif"></p><p></p> 
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Timebus">Timebus</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/119be4ad870849124a36d616.html#comment">查看评论</a>]]></description>
        <pubDate>2011-09-08  12:55</pubDate>
        <category><![CDATA[Timebus]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/119be4ad870849124a36d616.html</guid>
</item>

<item>
        <title><![CDATA[拉票~各位帮忙给我的参赛作品投一票啊！]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/200280fbdad2a50e6d22ebd6.html]]></link>
        <description><![CDATA[
		
		<p>我参加了腾讯的一个比赛，需要大家帮忙投票，网址如下：http://labs.soso.com/cstar2011/xq.html#project_id=1465 ，谢谢大家。还有http://dev.qq.com/match.php&nbsp;<font class="Apple-style-span" color="#000000"><a href="http://rrurl.cn/vCw4t1" target="_blank"></a>给“理财小助手”投一票啊。非常感谢! 求投票，求转发……</font></p><p><font class="Apple-style-span" color="#000000">大家帮忙在自己的朋友圈里给转一下，非常感谢！！！<img src="http://img.baidu.com/hi/jx2/j_0028.gif"></font></p><p></p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/200280fbdad2a50e6d22ebd6.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/200280fbdad2a50e6d22ebd6.html#comment">查看评论</a>]]></description>
        <pubDate>2011-06-15  13:38</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/200280fbdad2a50e6d22ebd6.html</guid>
</item>

<item>
        <title><![CDATA[工作分配，记下来]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/8d3d4d22570f3ee7d7cae2e1.html]]></link>
        <description><![CDATA[
		
		<p>第一部分：mapred包，mapreduce.filecache,hadoop.filecache包。里面总共161个java类，两个人看 <br>AID 11:57:09 <br>第二部分：<br>mapreduce,lib.input ,lib.map, lib.output, lib.partition, lib.reduce, lib.util, hadoop.util。共99个java类，一个人看。 <br>AID 11:57:52 <br>第三部分:<br>mapred.*, mapreduce.task, mapreduce.task,reduce。 共100个java类，一个人看 <br>AID 11:59:20 <br>第四部分：<br>.jobhistory, mapreduce.lib.*, .security, .security.token, .security.delegation, .server.jobtracker, .split 。 共108个java类。一个人看 </p>
<p>&nbsp;</p>
<p>嗯，悲剧的第四部分是我的……</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/8d3d4d22570f3ee7d7cae2e1.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/8d3d4d22570f3ee7d7cae2e1.html#comment">查看评论</a>]]></description>
        <pubDate>2011-02-23  16:17</pubDate>
        <category><![CDATA[默认分类]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/8d3d4d22570f3ee7d7cae2e1.html</guid>
</item>

<item>
        <title><![CDATA[“唱响西电”，冒了个泡……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/7369c895a22193077bf480be.html]]></link>
        <description><![CDATA[
		
		<p>昨天是唱响西电的初赛，之前跟小葛一起报名参加了，据说有加分，就准备去打个酱油~</p>
<p>小葛安排在4点多，我在六点多。不到四点我就跟小葛过去给他加油了，他唱了首灰姑娘，其实不应该挑这么一首歌的，前奏太长，调子又比较平淡，不能显示出他的歌喉和实力。因为前奏太长了，还导致他抢了一拍，音乐声盖过了他的歌声，结果就悲剧了。后来还有丫头她们实验室的几个人也去唱了，通过了两个，挺不错么。</p>
<p>最后一组，我排在11号，上去后有些紧张，调子倒是跟上了，不过后来由于忘词了，临时乱哼哼了几个字，然后赶紧把后面一段给拉到前面来唱了……不过好在陈奕迅这首兄妹并不是很多人熟悉，批评们应该也都没发现吧，呵呵。唱了估计就1分钟，就被喊停了，不过好在评为给了三张笑脸，刚刚过关，呵呵。让我想起来，之前那个院里的&ldquo;爱我中华&rdquo;爱国知识竞赛，本来就跟着打个酱油，结果三位美女实力强横啊，硬是拿了个冠军~专业打酱油啊……</p>
<p>今天是XDTIC的俱乐部活动，素质拓展。天虽然有点小雨，不过大家还是玩的很High，各种游戏都挺有意思。两人三足游戏，差了零点几秒，成了第二；那个过小呼啦圈的游戏，也是差零点几秒，成了第二；跳大绳大家很犀利啊，两分钟跳一百多，基本上没断过几次，可惜我被绊了一次，悲剧。。。最后那个猜数字的游戏，由于我们这边失误的动作设计，完完全全搞了个垫底。。。最后算总分，屈居第三啊，总过四个队。。。丫头她们第一，真假，哈哈哈~</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/7369c895a22193077bf480be.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Timebus">Timebus</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/7369c895a22193077bf480be.html#comment">查看评论</a>]]></description>
        <pubDate>2010-10-24  15:00</pubDate>
        <category><![CDATA[Timebus]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/7369c895a22193077bf480be.html</guid>
</item>

<item>
        <title><![CDATA[最近事情挺多的……]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/b9609efb1c4d8f6b024f567b.html]]></link>
        <description><![CDATA[
		
		<p>最近事情挺多的……</p>
<p>参加了个全国大学生软件创新大赛，这个比赛今年是第三届了，我们实验室的师兄曾在第一届的时候拿过二等奖。我们今年也侥幸进入决赛了，11月20号在东南大学的决赛将会决定我们取得什么成绩。坦白讲，做的东西还是不够成熟的，效果还是不太好，毕竟图像方面的知识还是太浅薄了。</p>
<p>另外，腾讯创新俱乐部里面的项目，要写一份计划书，16号之前还要上交。这也是我星火杯的作品之一，有丫头和栋哥帮忙，希望能顺利完成吧。坦白讲，可行性部分应该最不好写了。</p>
<p>丫头最近在北京学习，顺便玩，呵呵。看起来玩的还不错~</p>
<p>事情很多，努力……</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/b9609efb1c4d8f6b024f567b.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Timebus">Timebus</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/b9609efb1c4d8f6b024f567b.html#comment">查看评论</a>]]></description>
        <pubDate>2010-10-14  12:51</pubDate>
        <category><![CDATA[Timebus]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/b9609efb1c4d8f6b024f567b.html</guid>
</item>

<item>
        <title><![CDATA[POJ3468 线段树求和]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/29f4d63be88572e715cecbca.html]]></link>
        <description><![CDATA[
		
		<p align="center"> <font size="5">A Simple Problem with Integers</font></p>
<div class="plm">
<table class="FCK__ShowTableBorders" align="center">
    <tbody>
        <tr>
            <td><strong>Time Limit:</strong> 5000MS</td>
            <td width="10"> </td>
            <td><strong>Memory Limit:</strong> 131072K</td>
        </tr>
        <tr>
            <td><strong>Total Submissions:</strong> 12881</td>
            <td width="10"> </td>
            <td><strong>Accepted:</strong> 3131</td>
        </tr>
        <tr>
            <td style="color: #0ead00" colspan="3" align="center"><strong>Case Time Limit:</strong> 2000MS</td>
        </tr>
    </tbody>
</table>
</div>
<p class="pst">Description</p>
<p class="pst">You have <em>N</em> integers, <em>A</em><sub>1</sub>, <em>A</em><sub>2</sub>, ... , <em>A<sub>N</sub></em>. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.</p>
<p class="pst">Input</p>
<div class="ptx">
<p>The first line contains two numbers <em>N</em> and <em>Q</em>. 1 ≤ <em>N</em>,<em>Q</em> ≤ 100000.<br>
The second line contains <em>N</em> numbers, the initial values of <em>A</em><sub>1</sub>, <em>A</em><sub>2</sub>, ... , <em>A<sub>N</sub></em>. -1000000000 ≤ <em>A<sub>i</sub></em> ≤ 1000000000.<br>
Each of the next <em>Q</em> lines represents an operation.<br>
&quot;C <em>a</em> <em>b</em> <em>c</em>&quot; means adding <em>c</em> to each of <em>A<sub>a</sub></em>, <em>A<sub>a</sub></em><sub>+1</sub>, ... , <em>A<sub>b</sub></em>. -10000 ≤ <em>c</em> ≤ 10000.<br>
&quot;Q <em>a</em> <em>b</em>&quot; means querying the sum of <em>A<sub>a</sub></em>, <em>A<sub>a</sub></em><sub>+1</sub>, ... , <em>A<sub>b</sub></em>.</p>
</div>
<p class="pst">Output</p>
<div class="ptx">
<p>You need to answer all <em>Q</em> commands in order. One answer in a line.</p>
</div>
<p class="pst">Sample Input</p>
<pre class="sio">10 5
1 2 3 4 5 6 7 8 9 10
Q 4 4
Q 1 10
Q 2 4
C 3 6 3
Q 2 4</pre>
<p class="pst">Sample Output</p>
<pre class="sio">4
55
9
15</pre>
<p class="pst">Hint</p>
<div class="ptx">The sums may exceed the range of 32-bit integers.</div>
<p>/*<br>
懒得写了，直接用别人的介绍。。。代码自己写的。。。<br>
另外，C++的cin/cout输入输出流效率确实很低！<br>
用cin/cout读写此题跑了4800+ms，而改成C的scanf/printf只需要1600+ms<br>
其实算是一道比较基础的线段树的题了，但若用普通的毫不优化的线段树去做的话，绝对是会TLE的。<br>
这道题优化的思路就是，每次插入一个数字时，没必要把数字一直插入到叶子节点，<br>
只要有适合的范围就插入到这个范围中，用一个增量记录它，当下一次若有询问时，<br>
这个范围若刚好适合询问的范围，就直接把原来这个节点的值加上增量乘以范围，<br>
再加到SUM中，就可以了，若这个节点的范围不适合查询的范围的话，就要查询它的子节点了，<br>
那么这时候再把这个增量传递给它的子节点，这样在时间上效率就会比较高了。<br>
*/<br>
#include&lt;iostream&gt;<br>
#include&lt;string&gt;<br>
#include&lt;vector&gt;<br>
#include&lt;stack&gt;<br>
#include&lt;queue&gt;<br>
#include&lt;cmath&gt;<br>
#include&lt;map&gt;<br>
#include&lt;algorithm&gt;<br>
#define MAXN (1&lt;&lt;17)<br>
#define MAXOF(a,b) (a&gt;b?a:b)<br>
#define MINOF(a,b) (a&lt;b?a:b)<br>
#define MK(a,b) make_pair(a,b);</p>
<p>using namespace std;</p>
<p>struct Node{<br>
 int left;<br>
 int right;<br>
 __int64 cnt;<br>
 __int64 plus;<br>
};</p>
<p>Node SegTree[2*MAXN];<br>
int num[MAXN];<br>
int n,tn;</p>
<p>void initTree(int s,int t,int tid)<br>
{<br>
 SegTree[tid].left = s;<br>
 SegTree[tid].right = t;<br>
 SegTree[tid].cnt = 0;<br>
 SegTree[tid].plus = 0;<br>
 if( s == t)<br>
&nbsp;&nbsp; return ;<br>
 int mid = (s + t) / 2;<br>
 initTree(s,mid,(tid&lt;&lt;1)+1);<br>
 initTree(mid+1,t,(tid&lt;&lt;1)+2);<br>
}<br>
void BuildSegTree(int s,int t)<br>
{<br>
 tn = 1;<br>
 int i,j;<br>
 while(tn &lt; t+1)<br>
&nbsp;&nbsp; tn &lt;&lt;= 1;<br>
 initTree(s,tn-1,0);<br>
 for(i = tn - 1; i &lt; tn + n -1; i++)<br>
 {<br>
&nbsp;&nbsp; SegTree[i].cnt = (__int64)num[i - tn +1];<br>
 }<br>
 for(i = tn/2; i &gt;= 1; i /= 2)<br>
 {<br>
&nbsp;&nbsp; for(j = i - 1; j &lt; (i&lt;&lt;1) - 1; j++)<br>
&nbsp;&nbsp;&nbsp; SegTree[j].cnt = SegTree[(j&lt;&lt;1)+1].cnt + SegTree[(j&lt;&lt;1)+2].cnt;<br>
 }<br>
}<br>
void InsertSeg(int s,int t,int tid,__int64 wt)<br>
{ <br>
 if(SegTree[tid].left == s &amp;&amp; SegTree[tid].right == t)<br>
 {<br>
&nbsp;&nbsp; SegTree[tid].plus += wt;<br>
&nbsp;&nbsp; return ;<br>
 }<br>
 if(SegTree[tid].left == SegTree[tid].right)<br>
&nbsp;&nbsp; return ;<br>
 SegTree[tid].cnt += (__int64)(t - s + 1) * wt;<br>
 int mid = (SegTree[tid].left + SegTree[tid].right)&gt;&gt;1;<br>
 if(s &gt; mid)<br>
 {<br>
&nbsp;&nbsp; InsertSeg(s,t,(tid&lt;&lt;1)+2,wt);<br>
 }<br>
 else if(t &lt;= mid)<br>
 {<br>
&nbsp;&nbsp; InsertSeg(s,t,(tid&lt;&lt;1)+1,wt);<br>
 }<br>
 else <br>
 {<br>
&nbsp;&nbsp; InsertSeg(s,mid,(tid&lt;&lt;1)+1,wt);<br>
&nbsp;&nbsp; InsertSeg(mid+1,t,(tid&lt;&lt;1)+2,wt);<br>
 }<br>
}<br>
__int64 QueryTree(int s,int t,int tid,__int64 plus)<br>
{<br>
 plus += SegTree[tid].plus;<br>
 if(SegTree[tid].left == s &amp;&amp; SegTree[tid].right == t)<br>
&nbsp;&nbsp; return SegTree[tid].cnt + (t - s + 1) * plus;<br>
 if(SegTree[tid].left == SegTree[tid].right)<br>
&nbsp;&nbsp; return SegTree[tid].cnt + plus;<br>
 int mid = (SegTree[tid].left + SegTree[tid].right)&gt;&gt;1;<br>
 if(s &gt; mid)<br>
&nbsp;&nbsp; return QueryTree(s,t,(tid&lt;&lt;1)+2,plus);<br>
 else if(t &lt;= mid)<br>
&nbsp;&nbsp; return QueryTree(s,t,(tid&lt;&lt;1)+1,plus);<br>
 else<br>
&nbsp;&nbsp; return QueryTree(s,mid,(tid&lt;&lt;1)+1,plus) + QueryTree(mid+1,t,(tid&lt;&lt;1)+2,plus);<br>
}<br>
int main()<br>
{<br>
 int i,t,s,tmp;<br>
 __int64 modify;<br>
 char ch;<br>
 scanf(&quot;%d%d&quot;,&amp;n,&amp;tmp);<br>
 for(i = 0; i&lt; n ; i++)<br>
 {<br>
&nbsp;&nbsp; scanf(&quot;%d&quot;,&amp;num[i]);<br>
 }<br>
 BuildSegTree(0,n-1);<br>
 while(tmp--)<br>
 {<br>
&nbsp;&nbsp; getchar();<br>
&nbsp;&nbsp; scanf(&quot;%c&quot;,&amp;ch);<br>
&nbsp;&nbsp; if(ch == 'Q')<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; scanf(&quot;%d%d&quot;,&amp;s,&amp;t);<br>
&nbsp;&nbsp;&nbsp; printf(&quot;%I64d\n&quot;,QueryTree(s-1,t-1,0,0));<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; else<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; scanf(&quot;%d%d%I64d&quot;,&amp;s,&amp;t,&amp;modify);<br>
&nbsp;&nbsp;&nbsp; InsertSeg(s-1,t-1,0,modify);<br>
&nbsp;&nbsp;&nbsp; //cout&lt;&lt;&quot;Wait&quot;&lt;&lt;endl;<br>
&nbsp;&nbsp; }<br>
 }<br>
 system(&quot;pause&quot;);<br>
 return 0;<br>
}</p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/29f4d63be88572e715cecbca.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/29f4d63be88572e715cecbca.html#comment">查看评论</a>]]></description>
        <pubDate>2010-07-28  11:30</pubDate>
        <category><![CDATA[acm&#47;icpc]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/29f4d63be88572e715cecbca.html</guid>
</item>

<item>
        <title><![CDATA[大学毕业，最多的是不舍]]></title>
        <link><![CDATA[http://hi.baidu.com/wangyucao1989/blog/item/4cb554cbb5c4d0f052664ff8.html]]></link>
        <description><![CDATA[
		
		<p>大四是个蛋疼的季节，作为一个毕业后仍然留在西电的人，对毕业的感觉并没有那么强烈。已经在老校区实验室呆了很久了，经常泡在新老校区之间，这学期大半时间都是在老校区这边的，这使我错过了很多本应在新校区跟兄弟们一起度过的精彩。</p>
<p>6月12号，我完成了本科毕设答辩，之前在实验室有过一次模拟答辩，发挥很烂，竟然笑场。。。不过好在正式答辩时发挥超常，结果还是不错的，当然，这和丫头在下面看着我为我加油也是很有些关系的，O(∩_∩)O~</p>
<p>6月16号晚上，学士服发下来了，兄弟姐妹们一起照了很多照片，然而这一刻，我还是没有多少毕业的觉悟，只知道穿着学士服嘻嘻哈哈。宿舍的兄弟们还在一起，虽然腿腿没赶上集体照，但是总算赶上和宿舍兄弟一起照学士服照了。</p>
<p><span><img class="blogimg" border="0" small="0" src="http://hiphotos.baidu.com/wangyucao1989/pic/item/9fe4731e7d42082140341724.jpg"></span></p>
<p><span>6月17号晚上的散伙饭，班里的兄弟姐妹基本都去了，我们一起喝酒，一起海侃，一起唱歌，一起疯狂。那天晚上，女生们做了一晚上活背景，呵呵。直到吃晚饭回宿舍，还有一帮兄弟坐在我们宿舍外面的过道里，喝着酒，抽着烟，聊着未来和人生。。。</span></p>
<p><span>之后的时间过的好快，不断的跟兄弟们吃饭喝酒，老三说：&ldquo;哥人缘好，一天吃好几顿&rdquo;。老方是宿舍的奥斯卡影帝。老寒腿其实非常能喝。老二闷着头喝酒，千杯不醉。老徐跑回家去风流快活了。</span></p>
<p><span>28号回新校区办离校手续，盖章要到处跑，整个06级的同学们都得在这两天改完章，结果那个队排的长的啊！还记得去财务处盖章，门外一群人在挤着，老方他们把我挤进厅里，我拿着一沓离校手续表去盖章，结果改完章没找到老方，一个人回宿舍了。。。老徐的院办公室章是我带过去盖的，这个章只能看清楚一半。。。</span></p>
<p><span>29号，毕业典礼，我跟腿腿大清早爬起来穿着学士服下去围观别人领奖，带着摄像机记录了优秀毕业生们领奖的时刻，我们也跟着傻开心。特别是丫头和老方在意的某女生上台领奖时，更是给了特写记录，呵呵。据老二说，他后来也去看了，不过没看到他。。。</span></p>
<p><span>7月1号，小连和波波要走了，我下午三点开会，一直到4点半左右开完会立马冲向火车站。好在小连是晚上6点40多的火车，还能赶上送他进站。我跟丫头送小连和波波进入候车室，看着小连踏上去重庆的火车，记得他走之前，我用力的抱了抱他，强压着语调跟他说了句一路顺风。看着火车离去，我跟丫头都没能忍住眼泪。。。晚上，又聚集起了菜田，爽一起送别廖，这都是三年多的战友啊，现在一个一个离开去远方时，毕业的感觉突然强烈的涌了上来。。。当天晚上，511宿舍吃饭，缺我。。。</span></p>
<p><span>7月2号，我早早回去了新校区，老方和老三要走了。结果等我9点多赶回新校区，老三已经离开宿舍了，看着他空空的床铺，我忍不住打了个电话给他，但是只说了几句话，实在压抑不住自己的情绪，就赶紧挂了。收拾好了我的东西，打包了行李，就像打包了四年的感情一样，异常的沉重。下午看到老方发的日志，方一个人在电脑前哭的稀里哗啦的，我也忍不住一个人在阳台放了点水。送方上了校车，本来打算送他去火车站的，但是想到昨天送小连的情形，我还是一个人走下了校车，我觉得还是一个人默默离开比较好。。。916上，给方打电话，但是显然无法用平稳的语调讲话，只好改成发短信。希望老方以后一切顺利，我应该很快去上海看你的。。。</span><span>兄弟们，喝完你桌子上的啤酒，勇敢的去闯吧！</span></p>
<p><span>是夜，难免失眠。。。<br>
</span></p> <a href="http://hi.baidu.com/wangyucao1989/blog/item/4cb554cbb5c4d0f052664ff8.html">阅读全文</a>
		
		<br/><b>类别：</b><a href="http://hi.baidu.com/wangyucao1989/blog/category/Timebus">Timebus</a>&nbsp;<a href="http://hi.baidu.com/wangyucao1989/blog/item/4cb554cbb5c4d0f052664ff8.html#comment">查看评论</a>]]></description>
        <pubDate>2010-07-02  23:15</pubDate>
        <category><![CDATA[Timebus]]></category>
        <author><![CDATA[wangyucao1989]]></author>
		<guid>http://hi.baidu.com/wangyucao1989/blog/item/4cb554cbb5c4d0f052664ff8.html</guid>
</item>

<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>


</channel>
</rss>
