- 博客(23)
- 资源 (6)
- 收藏
- 关注
原创 POJ 2752
#includeusing namespace std;const int MAX=400005;char s[MAX];int tmp[MAX];int len[MAX];char substr[MAX];void GetNext(char* p,int next[]) { int pLen = strlen(p); next[0] = -1;
2014-11-27 14:29:39 482
原创 STL string的关键函数
string::find()1. 如果string sub = ”abc“; string s = ”cdeabcigld“; s.find(sub) , s.rfind(sub) 这两个函数,如果完全匹配,才返回匹配的索引,即:当s中含有abc三个连续的字母时,才返回当前索引。 s.find_first_of(sub),
2014-11-27 00:01:27 532
原创 poj 3080 暴力法 KMP+暴力枚举
#include#includeusing namespace std;char DNA[10][61];//存储字符串char SubStr[61];//存储子串char MaxStr[61];//最长子串int main(){ int test; scanf("%d",&test); for(int i=1;i<=test;i++) { //初始化 memset
2014-11-26 23:18:21 512
原创 POJ 3461 KMP算法
#includeusing namespace std;int* Compute(char* P){ int m=strlen(P); int* PI=new int[m]; PI[0]=-1; int k=-1; for(int q=1;q<m;q++) { while((k>=0)&&(P[k+1]!=P[q])) k=PI[k]; if(P[k+1]==P[
2014-11-25 22:07:21 547
原创 poj 2418 Trie
#includeusing namespace std;int num;//树的数目class Trie{private: int count;//记录单词数 Trie* child[256];//子树指针public: Trie(){count=0;memset(child,0,sizeof(child));}; void Insert(Trie* root,char* wor
2014-11-24 23:45:36 590
原创 Runtime error 可能是scanf函数出现问题 poj3630
#include#include#includeusing namespace std;const int MAX=10010;int main(){ string str[MAX]; int test; scanf("%d",&test); while(test--){ int n; scanf("%d",&n); for(int i=0;i<n;i++)
2014-11-24 18:50:06 1249
原创 poj 3630 Trie树, WA到想哭了
#include#includeconst int MAX=100005;class Trie{public: Trie() {clear();} int idx(char c) {return c-'0';} void clear() { size=1;memset(ch[0],0,sizeof(ch[0]));} bool insert(char* s);
2014-11-24 15:55:10 523
原创 字符串的处理 gets 与sscanf
char s[20]; int period,num; Node Item; while(gets(s)) { if('#'==s[0]) break; sscanf(s,"%d%d",&num,&period); Item.Q_num=num; Item.Time=period; q.push(Item); }说明:ge
2014-11-24 09:06:46 748
转载 北大ACM题目分类
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 最近AC题:2528 更新时间:2011.09.22 已AC题数:146初级题已在2011.06.30全部完成 部分解题报告添加新内容,除了原有的“大致题意”和“解题思路”外,新增“So
2014-11-22 16:43:26 704
原创 简单实现智能指针
#ifndef _SMART_PTR_H#define _SMART_PTR_Htemplateclass CSmartPtr{private: T* m_pT;public: //构造函数 explicit CSmartPtr(T* p=NULL); //~析构函数 ~CSmartPtr(); T& operator*()const t
2014-11-22 13:30:06 449
原创 设计一个简单的空间配置器 JJ::allocator
#ifndef _JJALLOC_#define _JJALLOC_#include//for placement new#include//for ptrdiff_t,size_t#include//for UINT_MAX#include//for cerrnamespace JJ{ template inline T* _allocate(ptrdiff_t size
2014-11-22 09:39:09 1072
原创 poj2002 STL pair解法
#include#includeusing namespace std;//**************常量****************//const int MAX=1001;int N;//*************算法变量************//pair point[MAX];int main(){ int l,ax,ay,bx,by,dx,dy,coun
2014-11-21 10:42:36 486
原创 POJ 2002 二分法
#include#includeusing namespace std;//**************常量****************//const int MAX=1001;int N;//*************算法变量************//struct Node{ int x; int y;};Node point[MAX];//比较函数bool
2014-11-21 09:50:13 572
原创 POJ 2503 Hash
#includeusing namespace std;//**************常量定义****************//const int M = 149993; const int MAX=100000;//**************算法变量***************//int HashIndex[M];//存储hash值对应的元素下标int len;st
2014-11-20 20:36:00 504
原创 POJ 2503 二分法
#include#includeusing namespace std;//****************常量定义*******************//const int MAX=100001;//****************算法变量******************//struct Node{char English[11];cha
2014-11-20 18:59:53 539
原创 POJ 1840
#includeusing namespace std;//**************常量定义*********************//const __int64 MAX=18750000;char Hash[2*MAX+1];void SetUpHash(int coe[6]){ int x1,x2; __int64 key; for(x1=-50;x1<=50;x1+
2014-11-19 19:18:07 497
原创 POJ 2709 贪心算法 测试数据生成程序
#includeusing namespace std;//*****************算法变量************************//const int Max=20;int InputNum;//输入N值;int InputArray[Max];int GrayNum;//灰色颜料的数量int ColorNum;//需要的颜料盒数//完成排序inline v
2014-11-18 10:38:55 650
原创 poj 1017 艰难的一个AC 贪心算法
#include#includeusing namespace std;int countBox;int count1Dot1;int count2Dot2;int Cal(int array[]){ int i,j,k; for(i=6;i>=1;i--) { switch(i) { case 6: { countBox+=array[6];
2014-11-17 20:36:12 706
转载 C#异常处理初探
try catch finally简单的三个关键字,其处理流程却较为复杂,下面先分各种情况讨论,最后得出结论,并提出使用建议。1 没有发生异常的情况
2014-11-12 21:03:31 440
原创 strlen和sizeof的区别
eg1、char arr[10] = "Hello"; int len_one = strlen(arr); int len_two = sizeof(arr); cout 输出结果为:5 and 10 点评: sizeof返回定义arr数组时,编译器为其
2014-11-08 18:42:51 429
machine learining Dimensionality Reduction (Week 8) exercise
2015-04-22
machine learning Regularization (Week 3) exercise
2015-04-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人