自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(31)
  • 资源 (1)
  • 收藏
  • 关注

原创 hdu 1078 FatMouse and Cheese

这一题考察的就是记忆化搜索。#include #include #include #include using namespace std;int map[105][105];int dp[105][105];int n,k;int dri[4][2]={1,0,-1,0,0,1,0,-1};int search(int a,int b){ in

2012-02-13 21:58:37 157

原创 hnu 1078 FatMouse and Cheese

这道题目就是考察的最基本的记忆化搜索。#include #include #include #include using namespace std;int map[105][105];int dp[105][105];int n,k;int dri[4][2]={1,0,-1,0,0,1,0,-1};int search(int a,int b){

2012-02-13 21:55:10 74

原创 hdu 1247 Hat’s Words

这一题也是用字典树做,思路比较简单,就是分两部分查找。左边一部分,右边一部分。这一题最主要的就是要注意结束条件。在Insert时候,要标记Insert单词的最后一个字母,一次来方便后面的search。#include using namespace std;#define MAX 26typedef struct Trie{ int count;

2011-12-18 20:51:44 232

原创 hdu 1251 统计难题

这是我第一次接触字典树,感觉还不是很不熟悉。这是仿照别人的代码写出来的。但是我还不是理解,为什么要用 #include #define MAX 26typedef struct TriNode{ int count; struct TriNode *next[MAX];}TriNode;int t=0;TriNode a[1000000];

2011-12-17 12:23:49 179

原创 hdu 1210 Eddy's 洗牌问题

这一题就是找规律的题目。。if(tt*=2;else {  t=2*(t-n)-1; }#include int main(){ int t,n; while(scanf("%d",&n)!=EOF) { int ans=1;

2011-12-10 00:04:16 191

原创 hdu 1028 Ignatius and the Princess III

在正整数n的所有不同划分中,将最大加数n1不大于m的划分个数记为q(n,m)。可以建立q(n,m)的如下递归关系:q(n,m) = 1, n >= 1当最大加数n1不大于1时,任何正整数n只有一种划分形式,n = 1 + 1 + 1 +...+ 1q(n,m) = q(n,n), m >= n最大加数n1实际上不能大于nq(n,n) = 1 + q(n,n - 1)正整数n

2011-12-07 22:26:59 126

原创 hdu 1019 Least Common Multiple

#include using namespace std;int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int main(){ int ca; scanf("%d",&ca); while(ca--) {

2011-12-03 20:45:16 139

原创 hdu 1005 Number Sequence

这道题目得出:周期为49; #include using namespace std;int a,b;int fun(int n){ if(n==1 || n==2) return 1; return (fun(n-1)*a%7 + fun(n-2)*b%7)%7;}int main(){ int n; wh

2011-12-03 20:29:00 139

原创 hdu 2795 Billboard

这一题可以用线段树来做,就是最简单的线段树。#include using namespace std;#define MAX 200010int w,fine;struct Node{ int r,l,mid,num,max;}node[3*MAX];int Max(int a,int b){ return a>b?a:b;}void i

2011-11-30 23:12:31 115

原创 hdu 4107 Gangster

解题思路:这一题与前面做的线段树的题目有所不同的就是这个子节点不一定一致(有可能子节点有节点的num值小于P),这样就不好进行优化,这里引用max,min两个变量用来储存该节点的子节点的最大值和最小值。若max=P,就可以+2*c,这样子节点就可以不用进行+c操作了,这样就可以进行偷懒了。#include using namespace std;#define INF 20

2011-11-27 11:09:12 141

原创 hdu 1698 just a hook

这道题目就是考察的线段树求和的算法,比较简单。注意事项:1、如果一个区间的值都相同,则用cover=value标记;2、如果区间的值原来都相同,现在要插入一个,则这个区间的cover值就为-1(用来标记这个区间的值不唯一)3、最后求总和的时候,用count函数求和。#include using namespace std;struct Nod

2011-11-26 11:34:25 129

原创 hdu 1698 Just a Hook

这道题目就是考察的线段树求和的算法,比较简单。注意事项:1、如果一个区间的zhi

2011-11-26 11:28:30 58

原创 hdu 1166

这道题目就是一道简单的线段树题目。与hdu1754很相似。#include using namespace std;struct Node { int l,r,mid,sum;}node [500000];void init(int a,int b,int n){ node[n].l=a; node[n].r=b; node[n].mid

2011-11-21 21:55:53 526

原创 hdu 1754

这是一道很基本的线段树题目。 #include using namespace std;struct Node{ int l,r,mid,max;}node[600000];int max(int a,int b){ return a>b?a:b;}void inint(int a,int b,int n){ nod

2011-11-21 20:38:51 1084 1

原创 hdu 4104 Discount

这道题目是很水的题目。不解释。。。。。#include #include using namespace std;int cmp(const void*a,const void *b){ int *t1=(int *)a,*t2=(int *)b; return *t1-*t2;}int main(){ int n,fine,min,sum;

2011-10-30 23:54:50 489

转载 hdu Squarefree number

#include#include#include#define nmax 1000001int prime[nmax], plen;void init() { memset(prime, -1, sizeof(prime)); int i, j; for (i = 2; i < nmax; i++) { if (prime[i]) { for (j = i + i; j

2011-10-23 12:05:00 174

原创 poj 2140 Herd Sums

这道题目水题。。。等差数列求和。分情况讨论,等差数列的长度为1,2,3,4,。。。直到t #include #include using namespace std;int main(){ int n; while(cin

2011-10-10 22:15:57 144

原创 hdu Self Numbers

这一题很简单,但是要注意mark数组开的范围应该大于1000000.#include #include using namespace std;bool mark[1010001];int change(int n){ int ans=0; whil

2011-10-06 16:51:59 128

原创 hdu 1114 Piggy-Bank

这题就是完全背包。注意要判断背包是否背满。初始化的时候要用dp[ ]=INF,dp[0]=0;#include #include using namespace std;#define INF 0x7ffffffint dp[10000];int end;in

2011-09-20 00:00:46 190

原创 hdu 1284 钱币兑换问题

这题主要是运用如下结论:设标记P(n, m)表示正整数n的所有不同划分中,最大加数不大于m的划分个数。               [  1             m = 1;P(n, m) = [  P(n, n)          n

2011-09-19 21:41:51 369

原创 hdu 1163 Eddy's digital Roots

这道题目只是考察基本的乘法运算:a*b就是将a的每位上的数字同乘以b就是结果。#include using namespace std;int change(int n){ int ans=0; while(n) { ans+=n

2011-09-19 14:24:57 114

原创 hdu 1162 Eddy's picture

这道题目就是考察的最小生成树。用prim算法即可轻松解出这道题目。#include #include #include #include using namespace std;#define MAX 10000000struct Node{ dou

2011-09-18 20:40:28 173

原创 hdu 1106 排序

其实这道题目很简单,只要注意几个地方就行了。1.5可以连续2.结束既可以以5结束,也可以不一5结束。   #include #include #include #include using namespace std;int cmp(con

2011-09-18 13:54:49 131

原创 poj 1107 W's Cipher

解题思路:用三个数组分别储存三个区间的字母出现的位置,再利用数组下标对应关系进行处理。注意:这题的n1,n2,n3均可以大于K1,K2,K3,所以要用到T=N1%K1。进行预处理。。。  #include #include #include #

2011-09-11 14:47:44 152

原创 poj 2420 A Star not a Tree?

题意:给你n个点要你求到这n个点的最短距离。这题可以从由这n个点构成的几何图形的几何中心开始搜索,搜索最小值。也可以用数学方法,求偏倒,不过过程复杂一点。#include #include #include #define MAX 1000000000

2011-09-01 11:02:47 136

原创 hdu 1078 FatMouse and Cheese

这题我原来使用暴力,超时了。。超时代码:#include #include #include int map[102][102],dp[102][102];int dri[4][2]={{0,-1},{1,0},{0,1},{-1,0}};int num,k

2011-08-29 16:13:25 207

原创 hdu 1081 To The Max

题意:求n*n矩阵子矩阵,使他的和最大。这题是一个最大子序列和的一个变形,我们可以将每个子矩阵的序列表示出来,再求子矩阵序列的最大子序列和。代码:#include #include #include int n,map[101][101];int a[10

2011-08-29 11:18:47 174

原创 hdu 1055 Color a Tree

刚开始做这道题目的时候完全没思路,参考了一下别人的代码,还是有一点弄不懂:为什么node[node[pos].prarent].w=(double)node[node[pos].prarent].c/node[node[pos].prarent].t;???有哪位大牛能帮忙解

2011-08-26 16:13:31 685 1

原创 hdu 1041 Computer Transformation

其实这道题目就是考查大数的乘法和加减法而已。。。这道题目的规律可以找出来:if(n&1){a[n]=2*a[n-1]-1;}elsea[n]=2*a[n-1]+1;我的ac代码:#include #include #include

2011-08-24 18:47:03 403

原创 hdu 1035 Robot Motion

这题其实很简单,但是我还是花了很长的时间,原因在于我没有考虑一种特殊的情况:从开始位置出发,再回到出发位置。。。所以dfs开始的时候要从1开始,而不是0.。。。 #include #include #include char map[15][15];i

2011-08-24 12:06:12 178

转载 hdu 3555 Bomb

典型的数位dp,也是最简单的数位dp,为了弄懂什么事s数位dp我真的纠结了很久,终于让我弄明白了一点了,只是有一点眉目。这两天下来,我发现其实数位dp用dfs实现的代码其实就是一个模板,只要弄懂模板就可以解决大部分问题了。(这要读者自己去慢慢体会。。。)最重要的dp数组中(dfs

2011-08-23 22:37:19 54

湖南大学微软俱乐部 c语言试卷

试卷试题简单,主要针对与c语言初学者。主要针对考试,有很大的帮助

2011-06-11

空空如也

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

TA关注的人

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