摘要: 先复习一个等比数列的公式:此题的答案是:k( x -1 ) + 1+ i我的解法:解这一道题的关键是充满想象力,k叉树是自相似的。也就是说:你只需要把每一层乘以k(也就是"放大"k倍)就得到也是一个k叉树,只不过没有根,而且是每层都是原k叉树向下平移了一层。每一层的下面一层,相当于把每一层放大k倍,也就是平移到下面一层了。所以,在这道题目中,我要想得到下一层X编号节点所在的那个位置的编号,只需要把k (X - 1) 就得到放大后的k叉树X的那个位置之前的点数总和,最后再+1,因为刚才没算根。这里有个问题,怎么利用上刚才的等比数列求和公式的结论呢?因为:这个k叉树每层的元素个 阅读全文
posted @ 2012-12-10 12:56 sharpstill 阅读(1095) 评论(0) 推荐(0) 编辑
摘要: linux运维人员的好帮手啊,太有用了! 阅读全文
posted @ 2012-11-27 22:44 sharpstill 阅读(1470) 评论(0) 推荐(0) 编辑
摘要: 0.数据文件我爱你首都北京我爱你北京我爱你伟大首都北京首都我爱javacomego1.map#include <iostream>using namespace std;void map(){ string line; getline(cin,line); while(!cin.eof()){ cout << line << "\t" << "1" <<endl; getline(cin,line); }}int main(int argc,char** argv){ map();}2.redu 阅读全文
posted @ 2012-09-14 12:15 sharpstill 阅读(1306) 评论(0) 推荐(0) 编辑
摘要: scrapy是一个不错的开源爬虫,在windows上安装需要以下组件:1.setup-tools为了easy_install2.easy_installw3lib3. easy_installzope.interface4.下载scrapy的win32安装包,并安装5.下载twisted的win32安装包,并安装6.windows版lxml安装,去http://pypi.python.org/simple/lxml/下载一个egg文件,然后easy_install *.egg 阅读全文
posted @ 2012-05-26 23:07 sharpstill 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 原创作者:博客园sharpstill,转载请注明Scrapy是一款非常成熟的爬虫框架,可以抓取网页数据并抽取结构化数据,目前已经有很多企业用于生产环境。对于它的更多介绍,可以查阅相关资料(官方网站:www.scrapy.org)。我们根据官网提供的安装指南,来一步步安装,主要参考了http://doc.scrapy.org/en/latest/intro/install.html页面的介绍:view plainRequirements?0?9Python2.5,2.6,2.7(3.xisnotyetsupported)Twisted2.5.0,8.0orabove(Windowsusers:y 阅读全文
posted @ 2012-05-26 23:06 sharpstill 阅读(3604) 评论(0) 推荐(0) 编辑
摘要: package algorithm;/*** * * @author mac * */public class KMPMatchPattern { public static void main(String[] args) { String source = "abababaababacb"; String target = "abaabab"; KMPMatchPattern p = new KMPMatchPattern(); //int[] ne = p.next("abababab");//你可以测试一下next方法 ... 阅读全文
posted @ 2012-02-25 19:17 sharpstill 阅读(270) 评论(1) 推荐(0) 编辑
摘要: 编译环境vc 9#ifndef SCANALLFILES_H#define SCANALLFILES_H#include "boost/filesystem/operations.hpp"#include "boost/filesystem/path.hpp"#include <iostream>using namespace std;class ScanAllFiles{public: static const vector<string>& scanFiles(const string&,vector<s 阅读全文
posted @ 2012-02-21 11:53 sharpstill 阅读(7171) 评论(0) 推荐(0) 编辑
摘要: Student& st = CollegeStudent("eatman",22);其中CollegeStudent是Student的子类g++编译报错:main.cc: In function ‘int main()’:main.cc:8: error: invalid initialization of non-const reference of type ‘Student&’ from a temporary of type ‘CollegeStudent’临时对象是const的。所以const Student& st = CollegeSt 阅读全文
posted @ 2012-01-31 16:33 sharpstill 阅读(612) 评论(1) 推荐(0) 编辑
摘要: C++泛型模板类使用小结:泛型类可以让源代码“实现”文件cc 和 头文件分离,书写规则只要遵循如下所示:文件一:Test.h的泛型模版类的头文件#include <iostream>#ifndef TEST_H#define TEST_Htemplate <typename T>class Test{ private: T t; public: void echo(void); //这个方法就一个功能,把私有的T类型成员变量打印出来 Test(T);};#include "Test.cc" //注意这里,引入了他的"实现文件",代 阅读全文
posted @ 2012-01-31 14:12 sharpstill 阅读(1575) 评论(0) 推荐(0) 编辑
摘要: 转载自:http://www.ibm.com/developerworks/aix/library/au-unix-eclipse/index.htmlBuild UNIX software with EclipseBringing legacy code into a modern IDEChris Herborth (chrish@pobox.com), Freelance, Freelance WriterSummary: Become more productive with your own code and others by utilizing Eclipse's syn 阅读全文
posted @ 2012-01-27 11:24 sharpstill 阅读(2255) 评论(0) 推荐(0) 编辑