- 博客(30)
- 资源 (16)
- 收藏
- 关注
原创 pku acm 1032
有两种方法求解,(1)递归分解,这种方法很好想,但是超时(2)分析题目,得出一些基本规律。(参考了他人的想法)1, a[1] > 1Proof: If a[1] = 1, a[t] could be replacedby a[t] + 1 and a[t]+
2011-09-30 10:00:36 582
原创 Perl -d 调试perl程序
在控制台输入perldoc perldebug即可如何得到如何调试perl程序的文档。其中重要的命令如下:p expr Same as "print {$DB::OUT} expr" in the current package. In
2011-09-28 13:21:51 4470 1
原创 pku acm 1087
第一次碰到最大流的问题。虽然我知道最大流的算法,但是砬到这题是根本没想到用最大流来求解。解法参考了http://www.cppblog.com/NARUTOACM/archive/2010/03/01/108680.html。解决此题的关键在于流图的建立:1,
2011-09-27 19:08:59 728
翻译 Levenshtein distance
Levenshtein distanceThe Levenshtein distance is a metric for measuring the amount of difference between two sequences (i.e. an edit di
2011-09-26 19:27:37 1363
原创 HashTable的一个详细实现
注:修改完善于一个粗糙版本http://blog.csdn.net/aishen944/article/details/14835161,修改了原文代码中的错误2,主要解决了在扩容时hash效率较差的问题 #ifndef _HASHTABLE_H #de
2011-09-23 21:43:50 2581
翻译 cstdarg可变参数列表
va_listType to holdinformation about variable argumentsThis type is used as a parameter for the macros definedin cstdarg to retrieve t
2011-09-23 16:06:44 711
转载 查看宏展开之后的代码
原文来自:dadaguo3000的专栏#include #define MIN(x, y) (x < y ? x : y) #define TO_STRING(x) TO_STRING1(x) #define TO_STRING1(x) #
2011-09-22 16:26:17 1827
转载 HashTable实现
Hash函数,摘自glib中typedef char gchar; typedef short gshort; typedef long glong; typedef int gint; typedef gint gboolean;
2011-09-22 14:30:30 629
转载 pku acm 1077(双向宽度优先解法及HashTable优化算法)
原文来自:http://hi.baidu.com/gropefor/home 的博客中,代码写的非常精巧,强烈推荐。在第二版的优化中使用了HashTable来加速查询。这两个代码使我了解了两种算法,一种是双向宽度优先搜索,另一种就是实际的HashTable的应用,以前一直听说Ha
2011-09-22 14:12:34 1182
原创 pku acm 1077
非常经典的8数码问题,主要采用的算法是人工智能中的“有序搜索算法”,也有人称之为A算法。#include #include #include #include #include using namespace std;const int LEN
2011-09-21 21:46:05 603
原创 pku acm 1065
//贪心算法 #include #include #include #include using namespace std;typedef pair PINTINT;bool cmp1(PINTINT p1, PINTINT p2){ if (p1.
2011-09-21 12:02:21 538
原创 pku acm 1035
//Spell checker#include #include #include #include using namespace std;set dic;string dictxt[10005];int index = 0;bool isInDic
2011-09-20 22:06:19 461
原创 pku acm 1064
二分搜索的应用#include #include #include using namespace std;int intCables[10002];//单位cmbool numberCuts(int index,int k,int length)//c
2011-09-18 18:42:34 663
原创 pku acm 1061
解题思想:(x + step * m) % L = (y + step * n) % L则(x - y + step * (m - n) ) % L == 0 || ( y - x + step * (n - m)) % L == 0则(x - y + step
2011-09-12 10:46:03 546
原创 pku acm 1095
Trees Made to Order#include #include #include using namespace std;const int LEN = 30;class OrderTree{private: static int kinds[L
2011-09-11 09:48:15 483
原创 指向类的数据成员和函数指针
指向类成员的指针在C++语言中,可以定义一个指针,使其指向类成员或成员函数,然后通过指针来访问类的成员。这包括指向属性成员的指针和指向成员函数的指针。à 指向数据成员的指针在C++语言中,可以定义一个指针,使其指向类成员。当属性成员为静态和非静态时,指针的使用也有不同
2011-09-09 16:18:41 2793
原创 while(cin)的理解
Jery最早的意图是支持一个iostream class object的纯量测试,像这样:if ( cin )...为了让cin能够求得一个真假值,Jerry首先为它定义一个conversion运算符,即operator int()。在良好行为如上者,确实 可以正确运行。
2011-09-07 16:11:16 2143
原创 pku acm 1018
题目: http://poj.org/problem?id=1018解题报告:1)方式一(对应maxbp)分为两个集合S和S1:1:初始情况下S[ (65535, 0) ], S1 [ ]为空 输入第一批数据后:(100 25)( 150
2011-09-05 23:10:23 749
原创 vector中清除某个元素方法(erase)
给一个vector对象,如何实现遍历一个删除一个。这个问题主要考察vector的erase函数。erase函数的声明如下:iterator erase(iterator_Where);iterator erase(iterator_First,iterator_L
2011-09-05 14:27:11 10165
原创 pku acm 1017
#include #include #include using namespace std;int main(){ freopen("in.txt","r",stdin); int product[7]; while(cin>>product[1]>>p
2011-09-05 09:26:02 568
原创 pku acm 1029
#include #include #include using namespace std;int flg[1001];//标记硬币:0:初始状态;1:可疑的;2:正常的硬币int comp[100][1001];//存放比较过程char res[100];//存
2011-09-04 14:27:26 651
原创 pku acm 1014
/*Source CodeProblem: 1014 User: xudacheng06Memory: 284K Time: 0MSLanguage: C++ Result: Accepted Source Code*/ #include
2011-09-03 21:10:37 584
原创 字符特性char_traits定义,及其特化版本char_traits<char>,char_traits<wchar_t>
// iosfwd standard header#if _MSC_VER > 1000#pragma once#endif#ifndef _IOSFWD_#define _IOSFWD_#include #include #include #inc
2011-09-03 14:28:48 2857
翻译 Operator new函数
operator newvoid* operator new (std::size_t size) throw (std::bad_alloc);void* operator new (std::size_t size, const std::nothrow_t& no
2011-09-02 22:55:32 1111 1
原创 C++ Utilities四(Uninitialized memory的使用)
以下三个函数定义为头文件memory中,下面是其可能的实际代码。代码来源于《The C++ Standard Library》namespace std{ template void uninitialized_fill(ForwIter beg,ForwIter end
2011-09-02 22:42:34 742
转载 new 与 operator new,placement new
"placement new"? 它到底是什么东东呀?我也是最近几天才听说,看来对于C++我还差很远呀!placement new 是重载operator new的一个标准、全局的版本,它不能被自定义的版本代替(不像普通的operator new和operator delet
2011-09-02 21:26:02 448
原创 pku acm 1013
#include #include #include using namespace std;const int WEIGHT = 2;//标准银元重量为2int getWeight(string s,char ch,int w)//ch为假银元,重量为1或3{
2011-09-02 15:00:38 471
原创 pku acm 1012
#include #include #include #include #include #include using namespace std;int joseph_m(int k){ vector vint,vint_b; int i,j,m; in
2011-09-02 09:28:49 414
原创 pku acm 1033
//WA 了3次才AC,题目不难,但交的人不多,思想很简单,直接见代码#include #include #include #include #include #include using namespace std;int main(){ freopen
2011-09-01 09:50:19 457
C++标准程序库源代码(The C++ Standard Library)
2011-08-28
Visual C++ 6.0数据库编程大全
2008-10-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人