ITeye博客

记录每天的点点滴滴

Dev|il · 共 103 篇文章

HDU2100Lovekey

Lovekey Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2812 Accepted Submission(s): 929 Problem Description XYZ-26进制数是一个每位都是大写字母的数字。 A、B、C、…、X、Y、Z 分别依次代表一个0 ~ 25 的数字,一个 n 位的26进制数转化成是10进制的规则如下 A0A1A2A3…An-1 的每一位代表的数字为a0a1a2a3…an-1 ,则该XYZ-26进制数的1…

2011-09-12 17:16 · 算法设计 · 评论(0)

HDU3368 Reversi(黑白棋)

Reversi Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 591 Accepted Submission(s): 251 Problem Description Reversi, also called Othello, is a two-sided game. Each of the two sides corresponds to one player; they are referred to here as light an…

2011-09-11 23:04 · 算法设计 · DFS · 评论(0)

HDU1010Tempter of the Bone

Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26363 Accepted Submission(s): 7218 Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to s…

2011-09-11 23:02 · 算法设计 · DFS · 评论(0)

求一个集合的全排列

[code="java"]#include using namespace std; const int _N = 10000; int d[_N], p[_N]; bool flag[_N]; int n; void dfs(int pos) { int i; if(pos == n) { for(i = 0; i < n; i++) cout<>n; memset(flag, false, sizeof(flag)); for(i = 0; i < n; i++) p[i] = i + 1; dfs(0); return 0; } [/code] [color=red]输入3 输出 1 …

2011-09-11 14:49 · 算法设计 · 评论(0)

HDU1175连连看

连连看 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6496 Accepted Submission(s): 1660 Problem Description “连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨…

2011-09-09 23:24 · 算法设计 · BFS · 评论(0)

HDU1711Number Sequence

Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3450 Accepted Submission(s): 1555 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000)…

2011-09-09 13:09 · 算法设计 · 串 · 评论(0)

串的模式匹配算法

c实现 [code="java"]#include using namespace std; //串的模式匹配算法 //返回字串t在主串s中第pos个字符后的位置,若不存在则返回0, 返回的位置可以是0 int Index(char s[], char t[], int pos) { int slen = strlen(s), tlen = strlen(t);; int i = pos, j = 0; while(i < slen && j < tlen) { if(s[i] == t[j]) { i++;j++; //继续比较字符 }else { i = i - j + 1;j = 0;…

2011-09-07 14:01 · 数据结构 · 串 · 评论(0)

HDU1097A hard puzzle

[align=center]A hard puzzle[/align] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13911 Accepted Submission(s): 4872 Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody…

2011-09-06 22:46 · 算法设计 · 评论(0)

串的顺序实现

[align=center]串的顺序实现[/align] 串的顺序结构实现有弊端: 1.串的最大长度固定 2.当串的长度超过MAXSTRLEN时,采用截尾法处理,这种方法不仅在求串的连接时可能发生,还在串的插入,置换也有可能发生. [code="java"]#include using namespace std; #define MAXSTRLEN 255 //用户可以在255以内定义最大串长 #define TURE 1 #define FALSE 0 #define ERROR 0 #define OK 1 typedef unsigned char SString[MAXSTRLEN…

2011-09-06 11:26 · 数据结构 · 串 · 评论(0)

HDU1004Let the Balloon Rise

[align=center]Let the Balloon Rise[/align] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 31804 Accepted Submission(s): 10554 Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, t…

2011-09-06 09:44 · 算法设计 · 评论(0)

队列的线性实现

继上篇文章 直接贴代码 [code="java"] #include using namespace std; #define ElemType int const int INIT_SIZE = 100; const int INCREMENT_SIZE = 10; //缺点:浪费空间 class Queue{ private: int front; int rear; int queue_total_size; ElemType *data; public: bool InitQueue(); //构造一个空队列 void DestoryQueue(); //销毁队列 void Clea…

2011-08-25 15:50 · 数据结构 · 队列 · 评论(0)

3.4.2 -队列的链式表示和实现

[align=center][size=large]队列的链式表示和实现[/size][/align] 队列是一种先进先出的数据结构,和食堂排队打饭类似,在前面的先打到饭,而后来者只有等前面的打完饭,后面的才能进行 以下给出C++实现 [code="java"]#include using namespace std; #define ElemType int typedef struct QNode{ ElemType data; struct QNode *next; }Node, *NodePtr; //72 //链队列 class Queue{ private: NodePtr fr…

2011-08-25 12:53 · 数据结构 · 队列 · 评论(0)

HDU2061Treasure the new start, freshmen!

Treasure the new start, freshmen! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4758 Accepted Submission(s): 1543 Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No matter what's your major, the…

2011-08-24 14:06 · 算法设计 · 评论(0)

HDU2251Seinfeld

Seinfeld Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 736 Accepted Submission(s): 381 Problem Description I’m out of stories. For years I’ve been writing stories, some rather silly, just to make simple problems look difficult and complex prob…

2011-08-24 13:39 · 算法设计 · 评论(0)

链栈的实现

[code="java"]#include using namespace std; #define ElemType int typedef struct LNode{ ElemType data; struct LNode *next; }Node; //链栈 class ListStack{ private: Node *head; int list_stack_size; Node * curr; public: ListStack() { list_stack_size = 0; head = curr = NULL; } bool push(ElemType e); //入栈 v…

2011-08-24 10:13 · 数据结构 · 栈 · 评论(0)