
基础算法
一些使用c实现的基本的算法
黄小鱼ZZZ
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
常见正则表达式
马上就要过年了,过得好快啊,下周末就要回家了。。。。在平常做项目的过程中都会用到校验,来对用户输入的信息进行过滤,以防操作者恶意破坏系统,我对正则表达式了解得不太多,用的时候都是参考网上的正则表达式,在这里总结一下平常经常食用的正则,方便以后使用,也方便大家参考。邮箱正则表达式验证:"^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$";手机号正则表原创 2017-01-15 22:15:35 · 551 阅读 · 0 评论 -
正则表达式
在大神的基础上进行修改的代码,判断邮箱的正确格式本代码在dev上边不能运行,在vc6.0上边也不能运行(在网上搜的说是要导入boost库),感觉麻烦就在VS2013上边运行了#include "stdafx.h"#include#include#include#includeusing namespace std;int main(){ string email_adress原创 2015-05-19 22:11:07 · 554 阅读 · 0 评论 -
正则表达式
编程思想之正则表达式 什么是正则表达式?正则表达式(Regular Expression)就是用某种模式去匹配一类字符串的公式。如你要在一篇文章中查找第一个字是“罗”最后一个字是“浩”的三个字的姓名,即“罗*浩”;那么“罗*浩”就是公式,也称作模式(Pattern),这篇文章就是要匹配的串(或叫文本text)。再如,你要检查输入的一个字符串是否是126邮箱的格式,你得制定一个规则去转载 2015-05-12 14:40:24 · 1305 阅读 · 0 评论 -
hdu-1864 最大报销额
简单的背包题 ;好无奈,我又没做出来在考试的时候代码:#include#include#includeusing namespace std;double dp[60],money[60];double total;int num,i,j,n,k,t;double max(double a,double b){ return a>b?a:b;}int main(){ in原创 2014-11-26 13:18:41 · 762 阅读 · 0 评论 -
背包问题详解(转)
背包问题是在1978年由Merkel和Hellman提出的。它的主要思路是假定某人拥有大量物品,重量各不同。此人通过秘密地选择一部分物品并将它们放 到背包中来加密消息。背包中的物品中重量是公开的,所有可能的物品也是公开的,但背包中的物品是保密的。附加一定的限制条件,给出重量,而要列出可能的物品,在计算上是不可实现的。背包问题是熟知的不可计算问题,背包体制以其加密,解密速度快而其人注目。但是,大多数转载 2014-11-09 22:33:15 · 675 阅读 · 0 评论 -
hdu- 2602 Bone Collector
Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave原创 2014-11-09 22:45:21 · 369 阅读 · 0 评论 -
hdu 1022
http://acm.hdu.edu.cn/showproblem.php?pid=1022#include#include#includeusing namespace std;int main(){ int n,i,j,k; bool io[20]; char str[20]; char str_1[20]; while(cin>>n>>str>>str_1){原创 2015-07-08 00:08:36 · 638 阅读 · 0 评论 -
hdu-2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
我想到的根本都不是背包问题,看来是我想得太简单了。。。代码,借鉴别人的#include#include#includeusing namespace std;struct node{ int p,h,c,value; }s[300];int main(){ int N,m; int n,sum; int dp[300]; in原创 2015-02-07 23:43:24 · 523 阅读 · 0 评论 -
nyoj-16
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=16有好几天都没有做题目了,本来自己就太弱,还不勤加练习,沉沦了一段时间,想想还是做题好,那样的话,充实这道题目用的是动态,感觉之前好像做过代码:#include#include#includeusing namespace std;struct node{ int原创 2015-01-05 17:44:25 · 506 阅读 · 0 评论 -
nyoj-49 开心的小明
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=49代码:#include#include#define max(a,b) a>b?a:bint main(){ int du[230],value[230],dp[120200]; int total,num; int i,j,k,t,n; scanf("%d",&n)原创 2014-12-21 09:37:17 · 678 阅读 · 0 评论 -
nyoj-325 zb的生日
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=325本道题目使用的是0-1背包,不过貌似用0-1背包效果不怎么好,参考别人的代码险过~我的代码:#include#include#includeusing namespace std;//int max(int a,int b){// return a>b?a:b;//}原创 2014-12-16 18:56:13 · 644 阅读 · 0 评论 -
hdu-1267下沙的沙子有几粒?
下沙的沙子有几粒?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2823 Accepted Submission(s): 1480Problem Description2005年11月份,我们学校参加了ACM原创 2014-10-25 12:43:10 · 462 阅读 · 0 评论 -
hdu 1003 Max Sum
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +原创 2014-11-21 21:05:03 · 1374 阅读 · 0 评论 -
nyoj-289 苹果
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=2890-1背包水过~~我的代码:#include#include#includeusing namespace std;int main(){ int dp[1200]; int i,j,k,t; int n,v,a,b; while(~scanf("%d%d",&n,原创 2014-12-16 18:59:09 · 553 阅读 · 0 评论 -
nyoj-17 单调递增最长子序列
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=17跟做的上一道题目几乎一样,关键地方的代码改一下就行了代码:#include#include#includeusing namespace std;char str[10010];int dp[10010];int main(){ int n; int i,j,k,t;原创 2014-12-18 21:51:00 · 570 阅读 · 0 评论 -
nyoj-79 拦截导弹
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=79代码:#include#includeint main(){ int dp[30],num[30]; int ans,temp,i,j,k,t,n,m; scanf("%d",&n); while(n--){ scanf("%d",&m); memset原创 2014-12-18 21:21:42 · 574 阅读 · 0 评论 -
nyoj-456 邮票分你一半
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=4560-1背包问题,现在发现我对0-1背包问题有点理解了我的代码:#include#include#includeusing namespace std;int main(){ int n,m; int dp[100010]; int num[100010]; int原创 2014-12-16 23:22:09 · 761 阅读 · 0 评论 -
hdu 1015 Safecracker 搜索
http://acm.hdu.edu.cn/showproblem.php?pid=1015#include#include#includeusing namespace std;char zifu[2000],str[20],str1[20];int mark[1000],k,num,flag;int cmp(const void *a,const void *b){ retur原创 2014-12-08 22:47:48 · 493 阅读 · 0 评论 -
hdu-1241 Oil Deposits
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241原创 2014-11-25 11:39:53 · 524 阅读 · 0 评论 -
hdu 2209 翻纸牌游戏
题目链接:搜索题,有两种情况,两种有一种不考虑的话就会WA....代码:#include#include#define INF 999999999//定义一个最大的数 #includeusing namespace std;int num;int shu1[30];char str[30];int ans,m;int dfs(int n,int num,int m){ if原创 2014-12-09 21:09:13 · 621 阅读 · 0 评论 -
hdu-1312 Red and Black
Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjace原创 2014-11-16 16:13:05 · 453 阅读 · 0 评论 -
hdu-1010 Tempter of the Bone 简单的搜索
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010做这道题目的时候需要注意剪枝,如果没有剪枝的话,就会超时注意奇偶剪枝代码:】#include#include#includechar map[20][20];int top[4][2]={{0,1},{0,-1},{1,0},{-1,0}};int sx,sy,ex,ey,t原创 2014-11-29 11:00:31 · 626 阅读 · 0 评论 -
nyoj-58 最少步数 搜索
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=58比较简单的搜索题目,代码:#include#includeint map[9][9]={{1,1,1,1,1,1,1,1,1},{1,0,0,1,0,0,1,0,1}, {1,0,0,1,1,0,0,0,1},{1,0,1,0,1,1,0,1,1},原创 2014-11-29 10:51:38 · 690 阅读 · 0 评论 -
nyoj-27 水池数目
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=27代码:#include#include#includeint num[120][120];int top[4][2]={{1,0},{-1,0},{0,1},{0,-1}};int a,b,ans;void dfs(int x,int y){ num[x][y]=0;原创 2014-12-12 19:00:35 · 573 阅读 · 0 评论 -
hdu-1016 Prime Ring Problem 搜索题
Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.原创 2014-11-22 10:41:26 · 541 阅读 · 0 评论 -
hdu-1518 Square
SquareTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8922 Accepted Submission(s): 2903Problem DescriptionGiven a set of sticks原创 2014-11-05 19:50:59 · 512 阅读 · 0 评论 -
hdu-2616
Kill the monsterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 879 Accepted Submission(s): 639Problem DescriptionThere is a moun原创 2014-10-18 10:37:17 · 569 阅读 · 0 评论 -
hdu-2115
I Love This Game原创 2014-09-12 20:25:29 · 527 阅读 · 0 评论 -
hdu-2115
I Love This GameTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5596 Accepted Submission(s): 1941Problem DescriptionDo you like p原创 2014-09-12 20:58:34 · 447 阅读 · 0 评论 -
zoj 水题习题集
zoj-1312原创 2014-09-14 21:38:47 · 774 阅读 · 0 评论 -
博弈论基础知识
博弈论基础知识:巴什博奕+威佐夫博奕+尼姆博弈(及Staircase);(一)巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个.最后取光者得胜.若(m+1) | n,则先手必败,否则先手必胜。显然,如果n=m+1,那么由于一次最多只能取m个,所以,无论先取者拿走多少个,后取者都能够一次拿走剩余的物品,后者取胜.转载 2014-08-19 17:30:37 · 729 阅读 · 0 评论 -
nyoj-23
取石子(一)时间限制:3000 ms | 内存限制:65535 KB难度:2描述一天,TT在寝室闲着无聊,和同寝的人玩起了取石子游戏,而由于条件有限,他/她们是用旺仔小馒头当作石子。游戏的规则是这样的。设有一堆石子,数量为N(1<=N<=1000000),两个人轮番取出其中的若干个,每次最多取M个(1<=M<=1000000),最先把石子取完者胜利。我们知道,T原创 2014-10-30 14:55:14 · 492 阅读 · 0 评论 -
nyoj-135
取石子(二)时间限制:3000 ms | 内存限制:65535 KB难度:5描述小王喜欢与同事玩一些小游戏,今天他们选择了玩取石子。游戏规则如下:共有N堆石子,已知每堆中石子的数量,并且规定好每堆石子最多可以取的石子数(最少取1颗)。两个人轮流取子,每次只能选择N堆石子中的一堆,取一定数量的石子(最少取一个),并且取的石子数量不能多于该堆原创 2014-10-30 17:17:15 · 519 阅读 · 0 评论 -
hdu-5011 Game
Problem DescriptionHere is a game for two players. The rule of the game is described below:● In the beginning of the game, there are a lot of piles of beads.● Players take turns to play. E原创 2014-11-05 21:59:47 · 506 阅读 · 0 评论 -
hdu-1850
Being a Good Boy in Spring FestivalTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4842 Accepted Submission(s): 2893Problem Descrip原创 2014-10-29 21:55:54 · 645 阅读 · 0 评论 -
博弈
一.巴什博奕(Bash Game):首先我们来玩一个比较古老的报数游戏。A和B一起报数,每个人每次最少报一个,最多报4个。轮流报数,看谁先报到30.如果不知道巴什博弈的可能会觉得这个是个有运气成分的问题,但是如果知道的人一定知道怎样一定可以赢。比如A先报数的话,那么B一定可以赢(这里假定B知道怎么正确的报数)B可以这样报数,每次报5-k(A)个数,其中k(A)是A报转载 2014-10-30 15:28:48 · 538 阅读 · 0 评论 -
hdu1073
Online JudgeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5376 Accepted Submission(s): 2056Problem DescriptionIgnatius is build原创 2014-10-28 16:29:35 · 771 阅读 · 0 评论 -
nyoj-524
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=524对字符串进行比较的一道题目#include#includechar str1[120],str2[120];int havepoint(char *str){ int k; k=strlen(str); for(int i=0;i<k;i++) if(str[i原创 2015-01-06 22:43:37 · 521 阅读 · 0 评论 -
hdu-2203
亲和串#include#includeint main(){ char str1[101000]; char str2[101000]; char str3[202000]; while(gets(str1)!=NULL) { gets(str2); st原创 2014-09-14 21:37:36 · 530 阅读 · 0 评论 -
hdu-2054 A == B ?
Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print "YES", or print "NO". Inputeach test case contains two numbers A and B. Outputfor each case, i原创 2014-11-08 22:29:41 · 610 阅读 · 0 评论