自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(214)
  • 资源 (25)
  • 收藏
  • 关注

原创 【DFS】poj 1426 Find The Multiple

http://poj.org/problem?id=1426 #include #include #include using namespace std; typedef __int64 LL; const int NM=205; int n,vis[NM]; LL BFS(){ queueq1; LL t=1,x1,x2; int mod1,mod2; memse

2014-05-23 17:23:15 650

原创 【IDA*】hdu 1560

#include #include #include using namespace std; const int NM=10; char str[NM][NM],cs[4]={'A','C','T','G'}; int v[NM],len[NM],sta[NM],dep,n; bool flag; int compare()  //A*的估价函数 { i

2014-05-23 17:01:46 532

原创 【DFS】poj 1190 生日蛋糕

http://poj.org/problem?id=1190 #include #include using namespace std; const int MAX=0xfffffff; int mmins; int V,M; int Get_minV(int x){ return (x+1)*(x+1)*x*x/4; } /* V=PI*r^2*h; S(侧)=2*PI*r

2014-05-23 16:56:51 719

原创 【树形DP】hdu 1520 Anniversary party

http://acm.hdu.edu.cn/showproblem.php?pid=1520 #include #include #include #include using namespace std; const int NM=6005; int dp[NM][2],f[NM],a[NM]; vectorv[NM]; int max(int x,int y){ ret

2014-05-23 16:51:59 500

原创 【字典树+DFS】hdu 1298 T9

http://acm.hdu.edu.cn/showproblem.php?pid=1298

2014-05-18 21:35:36 565

原创 【拓扑排序】hdu 3342 Legal or Not

http://acm.hdu.edu.cn/showproblem.php?pid=3342 #include #include #include using namespace std; const int NM=105; int a[NM][NM],indu[NM],n; bool Tuopu(){ int i,j,k,ling; memset(indu,0,sizeof(

2014-05-17 18:47:28 472

原创 【拓扑排序】poj 1094 Sorting It All

http://poj.org/problem?id=1094

2014-05-17 17:57:41 463

原创 nyoj 927 The partial sum problem

#include #include #include #include using namespace std; const int NM=30; int a[NM],sum,n; bool flag; bool comp(int x,int y){ return x>y; } void DFS(int res,int i) { if(flag || i>n) return;

2014-05-16 21:35:02 601

原创 nyoj 43 24 Point game

http://acm.nyist.net/JudgeOnline/problem.php?pid=43 分析: #include #include #include #include using namespace std; const int NM=15; const double eps=1e-6; bool vis[NM],flag; double a[NM]; int n,m

2014-05-14 19:10:46 475

原创 【KMP(循环节)】poj 2406 Power Strings(外:hdu 1358 Period)

http://poj.org/problem?id=2406 #include #include #include using namespace std; const int NM=10000005; int next[NM]; char str[NM]; void get_next(){ int i,j,len; len=strlen(str); i=0;next

2014-05-12 20:01:18 539

原创 【并查集】hdu 1272 小希的迷宫

#include #include #include using namespace std; const int NM=100005; int father[NM]; bool vis[NM],flag; int Find(int x){ int t,p1=x; while(p1!=father[p1]) p1=father[p1]; while(x!=p1) { t=fath

2014-05-08 17:51:50 531

原创 【DFS(记忆化)】zzuli 1430 多少个0

#include #include #include using namespace std; const int NM=105; const int MAX=0xfffffff; int dp[NM][NM][2],a[NM][NM],mmin,n,m; int c[2][2]={1,0,0,1}; int MIN(int x,int y){ return x<y?x:y; } i

2014-04-23 11:06:30 520

原创 【DFS(记忆化)】hdu 2452 Navy maneuvers

http://acm.hdu.edu.cn/showproblem.php?pid=2452

2014-04-21 21:40:15 615

原创 【并查集】hdu 1856 More is better

#include #include #include using namespace std; const int NM=10000005; int father[NM],rank[NM],mmax; int Find(int x){ /*while(x!=father[x]) x=father[x]; return x; 超时*/ /*if(x!=father[x])

2014-04-21 19:45:24 457

原创 poj 1664 放苹果

http://poj.org/problem?id=1664

2014-04-17 19:35:31 453

原创 【DFS(记忆化)】hdu 1619 Unidirectional TSP

http://acm.hdu.edu.cn/showproblem.php?pid=1619

2014-04-16 20:37:38 614

原创 【DFS(记忆化)】poj 1351 Number of Locks

http://poj.org/problem?id=1351 题意:

2014-04-16 18:31:40 533

原创 【最短路径-Dis】hdu 1311 Relative Relatives

http://acm.hdu.edu.cn/showproblem.php?pid=1311 分析:

2014-04-12 14:19:18 737

原创 【DFS(记忆化)】hdu 1078 FatMouse and Cheese(poj 1088 滑雪)

#include #include #include #include using namespace std; const int NM=105; int a[NM][NM],vs[NM][NM],n,k,mmax; int d[4][2]={-1,0,1,0,0,-1,0,1}; int max(int x,int y){ return x>y?x:y

2014-04-10 17:20:01 570

原创 【DFS(记忆化)】hdu 1208 Pascal's Travels

http://acm.hdu.edu.cn/showproblem.php?pid=1208 分析:注意当出现0时,

2014-04-10 16:14:40 573

原创 第二章 递归与分治策略

2-5 整数划分问题

2014-04-08 14:55:02 475

原创 第四章 贪心算法

4.1 活动安排问题 分析:按照结束时间非递减排序,再贪心。 #include #include #include #include using namespace std; const int NM=105; bool x[NM]; struct Node{ int s,f; }q[NM]; bool comp(struct Node A,struct Node B){ re

2014-04-03 11:48:07 543

原创 【DFS】hdu 2616 Kill the monster

http://acm.hdu.edu.cn/showproblem.php?pid=2616 分析:排列树水过 #include #include #include using namespace std; const int NM=15; int cost[NM],x[NM],spe[NM],mmin,n; void DFS(int t,int MP,int cc) {

2014-04-02 20:03:02 508

原创 hdu 2209 翻纸牌游戏

http://acm.hdu.edu.cn/showproblem.php?pid=2209 分析:第1张牌的状态只受两种影响:自己和第2张牌;判断前一张牌是否为正面 #include #include #include #include using namespace std; const int NM=25; int mmin,len,a[NM]; bool flag

2014-04-01 18:33:33 675

原创 【DFS+BFS】hdu 1983 Kaitou Kid - The Phantom Thief (2)(迷宫)

http://acm.hdu.edu.cn/showproblem.php?pid=1983 分析:最多只用封锁四个位置就可以了(封锁起点或终点);判断路径是否经过时,再加一层宝石状态来判断(可以重复走) #include #include #include #include using namespace std; const int NM=10; int a[4][2]=

2014-03-30 19:44:41 696

原创 【DFS(记忆化)】hdu 1501 Zipper

http://acm.hdu.edu.cn/showproblem.php?pid=1501 分析:记忆化搜索 注释掉后反而更快了 #include #include //#include #include #include using namespace std; const int NM=205; char s1[NM],s2[NM],str[NM<<1]; int

2014-03-28 16:39:12 515

原创 【Bellman_Ford】poj 1860 Currency Exchange

http://poj.org/problem?id=1860 题意:A和B交换率相等(双向图),每次交换需要小费(可以交换多次),问经过一系列交换后(最后需要换回最开始的那种货币),资金能否增长? 分析:寻找正权回路 #include #include #include #include #include using namespace std; const int

2014-03-27 19:29:32 670

原创 【A*】hdu 1195 Open the Lock

http://acm.hdu.edu.cn/showproblem.php?pid=1195 题意:每一位上的数字可以加1或减1;相邻的数可以交换(第1个和第4个不相邻),变换得到下面的密码。 分析:两个评价函数:f=g+h(g:每一位上与答案不相同数字的个数;h:步数) #include #include #include #include using namespace

2014-03-27 19:18:04 478

原创 【BFS+Prim】poj 3026 Borg Maze

http://poj.org/problem?id=3026 题意:从S开始找到一条到所有外星人A的通路,使得该通路总长度最短。 分析:暴搜找出所有A/S之间的边,然后用prim把所有最短的边连接起来。 #include #include #include #include using namespace std; const int NM=105; /*k:外星人的个数,

2014-03-26 20:53:18 490

原创 第三章 习题(三)

5-12 罗密欧与朱丽叶的迷宫问题 注意:还可加入无解时的剪枝判断 [cpp] view plaincopyprint? #include    #include    #include    using namespace std;      const int NM=25;   int d[8][2]={-1,0,-1,1,

2014-03-23 23:33:46 1177

原创 第五章 习题(二)

5-9 拉丁矩阵问题 #include #include #include using namespace std; const int NM=25; int x[NM][NM],n,m,num,sum; bool check(int line,int row,int k) { int i,j; for(i=0;i<line;i++){ if(x[i][row]==k) ret

2014-03-22 13:56:57 697

原创 第五章 习题(一)

5-1 子集和问题 #include #include #include using namespace std; const int NM=25; int set[NM],x[NM],path[NM],n,Wleft,c; bool Backtrack(int cw,int t) { if(t>n){ for(int j=1;j<=n;j++) path[j]=x[j];

2014-03-18 14:50:37 755

原创 第五章 回溯法

5.2 装载问题 #include #include #include using namespace std; const int NM=100; int wi[NM],path[NM],x[NM],n,bestmax,Wleft,c; void Backtrack(int cw,int i) { if(i>n){ bestmax=cw; for(int j=1;j<=n;

2014-03-13 13:02:55 598

原创 poj 3032 Card Trick

http://poj.org/problem?id=3032 分析:如下图,模拟翻牌的过程 #include #include #include #include using namespace std; int main() { int T,i,j,n,t,a[20]; dequedq1; scanf("%d",&T); while(T--) { dq1.cl

2014-03-06 13:54:54 594

原创 poj 2456 Aggressive cows

http://poj.org/problem?id=2456 题意:在n个位置放置c只牛,使得每只牛之间的间距最大,求满足条件的最小间距? #include #include #include #include using namespace std; const int NM=100005; int a[NM],n,c; //判断在整个长槽内,间距>=x,是否可以放下

2014-02-19 18:12:22 541

原创 【最大流(dinic)】poj 1273 Drainage Ditches

http://poj.org/problem?id=1273 分析:最大流的dinic实现模板(邻接矩阵) #include #include #include #include using namespace std; const int NM=205; const int MAX=0xfffffff; int a[NM][NM],level[NM],n,m; inlin

2014-02-18 12:35:59 516

原创 【最大流(EK)】poj 1149 PIGS

http://poj.org/problem?id=1149 题意:有M个猪圈、N个顾客,每个顾客有A把钥匙;只能在有钥匙的猪圈购买最多B只猪,顾客购买过后,可以对打开的猪圈内的猪重新分配;求最多可以卖出多少头猪? 分析:经过大神的总结,得以建立以下图: 1)在原先的图中添加源点(0)和汇点(n+1); 2)源点连接的是每个猪圈的第一个顾客,如果一个顾客是多个猪圈的第一名买家,则将权值合并

2014-02-17 00:44:28 597

原创 【最大流(EK)】hdu 3549 Flow Problem

http://acm.hdu.edu.cn/showproblem.php?pid=3549 分析:最大网络流的EK算法 #include #include #include #include using namespace std; const int NM=20; const int MAX=0xfffffff; int a[NM][NM],pre[NM],n,m,ans

2014-02-15 18:45:19 587

原创 hdu 2817 A sequence of number

http://acm.hdu.edu.cn/showproblem.php?pid=2817 题意:求等差数列和等比数列 #include #include #include using namespace std; typedef __int64 LL; const int NN=200907; int main() { LL x,y,z,k,t,r,T; while(

2014-02-10 20:44:49 490

原创 【线段树(线段离散化+lazy)】poj 2528 Mayor's posters

http://poj.org/problem?id=2528 题意:有不同长度([x,y])的海报被贴在一个长墙上,求有多少个海报可以被看到(只要有一部分漏在外面就算) 分析:离散化的时候是对线段而不是对点离散,否则会错误,因为即使是[1,1]也表示一个线段,比如下例: li ri 1 10 1 3 6 10 清除相同项

2014-02-09 20:14:52 766

树状数组讲解

树状数组的基本实现,详解详细,十分清晰,适合初学者

2013-04-17

商品货架管理

问题描述] 商店货架以栈的方式摆放商品。生产日期越近的越靠近栈底,出货时从栈顶取货。一天营业结束,如果货架不满,则需上货。入货直接将商品摆放到货架上,则会使生产日期越近的商品越靠近栈顶。这样就需要倒货架,使生产日期越近的越靠近栈底。

2013-03-22

一个简单的绘图应用程序

一个简单的绘图应用程序:画圆、移动正方形、画线等

2006-03-14

数据结构教材

数据结构学习的经典教材,大学计算机的必修课程

2013-04-17

哈夫曼树的实现

哈夫曼树的建立,编码及译码,各种实现细节,用优先队列选择

2013-04-22

共享文件夹的设立

文件共享,选择“安全”,可以看到此时可以访问这个文件夹的用户没有“Guest”,点击“添加”

2013-12-13

SORT_SEARCH

数据结构实验各种排序和查找,如:哈希表、二分;归并、快排等

2013-06-04

杭电离线题库

杭电的离线题库,不用上网就可以刷题

2013-04-17

解决asf文件没有声音

asf格式的文件没有声音怎么办? 安装asf的音频解码器,然后重新打开文件

2013-10-20

离散数学的教材

离散数学是数据结构树和图的基本介绍,还有其他各种路基关系

2013-04-17

回文字符串

[问题描述] 对于一个从键盘输入的字符串,判断其是否为回文。回文即正反序相同。如“abba”是回文,而“abab”不是回文。

2013-03-22

Python基础教程(第2版)

Python基础教程(第2版)pdf,非常适合初学者

2013-03-13

约瑟夫环-各种实现

多种方法实现约瑟夫环,对线性数据结构有更好的理解

2013-03-13

算法导论

算法导论的中文版,学习计算机的必备良书,以及参考之用

2013-04-17

算法设计与分析

经典的算法学习,是acm的必备精品,虽然内容有点难理解

2013-04-17

挑战编程中文

学习acm的入门教材,包括基本内容和各种语法控制等

2013-04-17

Linux+C+函数

很方便查照Linux下的各种C函数,还有例子哦

2013-04-17

c and c 库函数手册

c and c 库函数手册,方便查找基本函数

2013-03-22

学生管理系统

学生管理系统:实现添加、修改、删除等功能

2013-01-16

学生通讯系统

学生通讯系统:实现添加、修改、删除等功能

2013-01-16

简单计算器

可实现log,1/x,ln,x^y等高级功能

2013-01-17

基本控件功能

基本控件功能:编辑框的消失与再显示,组合框,单选框

2013-01-17

二叉树的各种实现

1. 按先序序列构造一棵二叉链表表示的二叉树T; 2. 对这棵二叉树进行遍历:先序、中序、后序以及层次遍历,分别输 出结点的遍历序列; 3. 求二叉树的深度/结点数目/叶结点数目; 4. 将二叉树每个结点的左右子树交换位置; 5.非递归算法实现二叉树中序遍历。

2013-04-15

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除