自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 Minimum Depth of Binary Tree

class Solution {public:int minDepth(TreeNode* root) {int res=0;bool flag = false;queue q;TreeNode *t;if (root == NULL)return 0;q.push(root);q.push(NULL);while (q.front() != NULL)

2017-11-16 09:57:42 141

原创 spring框架搭建与入门案例

spring是一个轻量级的支持控制翻转(inversion of control)和面向切面(aspect oriented programming)的轻量级的容器框架。

2017-03-18 12:01:29 1028

原创 约瑟夫环问题

约瑟夫环问题就是n个人围成一圈,数到m的人退出,求最后退出的人解决办法:n个人围成一圈,编号分别为0~n-1,数到m-1的人退出。第一次退出的人很明显为(m-1)%n,则剩下n-1个人,这就变成了求n-1个人中最后退出的人。将(m-1)%n以后的人再从0开始编号,这n-1个人的编号与开始n个人的编号相差为mf(n)表示n个人最后退出的编号当只有一个人时,f(1)=0,因为只

2016-10-17 11:06:16 929

原创 hdu 4565 So Easy!(矩阵+快速幂)

题目大意:就是给出a,b,n,m;让你求s(n);解题思路:因为n很可能很大,所以一步一步的乘肯定会超时,我建议看代码之前,先看一下快速幂和矩阵快速幂,这样看起来就比较容易,这里我直接贴别人的推导,应该很容易懂。看到这里你应该明白了大概吧!好吧现在继续看我的代码吧!!AC代码:#includelong long c[2][2],d[2];int main(){

2013-08-16 15:16:30 751

原创 hdu 2821 Pusher(dfs)

Problem DescriptionPusherBoy is an online game http://www.hacker.org/push . There is an R * C grid, and there are piles of blocks on some positions. The goal is to clear the blocks by pushing into t

2013-08-13 23:18:39 733

原创 hdu 2553 N皇后问题(dfs)

Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,

2013-08-13 16:58:07 472

原创 hdu 4492 Mystery

InputThe first line of input contains a single integer P, (1 The first line of each data set contains an integer D which is the data set number. The second line contains no more than the 93 dist

2013-08-12 21:52:15 535

原创 hdu 4488 Faulhaber’s Triangle

Problem DescriptionThe sum of the mth powers of the first n integersS(n,m) = SUM ( j= 1 to n)( jm)Can be written as a polynomial of degree m+1 in n:S(n,m) = SUM (k = 1 to m+1)(F(m,k) *nk)

2013-08-12 21:26:37 533

原创 hdu 4489 The King’s Ups and Downs

题目大意:有n个人,他们的身高依次升高,按照高矮高矮高矮.........的这种波形顺序排列求一共有多少种方法!解题思路:唉,搜索和dp对我都是硬伤,比赛时看了一下,根本就是无从下手,不知道动态转移方程式什么!下来问了别人,然后思考了一下,OMG!原来方程这么简单。首先我们假设已知前i-1,i-2,...1,个人排列数。然后我们来插入第i个人,由于第i个人是前i个人中最高的,所以他前面的和后面

2013-08-12 21:02:17 968

原创 hdu 1885 Key Task(bfs+状态压缩)

Problem DescriptionThe Czech Technical University is rather old — you already know that it celebrates 300 years of its existence in 2007. Some of the university buildings are old as well. And the na

2013-08-10 22:15:11 456

原创 hdu 1429 胜利大逃亡(续) (bfs+状态压缩)

Problem DescriptionIgnatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)……这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx,sy)的位置,离开地牢的门在(ex,ey)的位置。Ignatius每分钟只能从一个坐标走到相邻四个坐标中的其中一个。魔王

2013-08-10 21:42:22 568

原创 hdu 4336 Card Collector

DescriptionIn your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in the famous novel Water Margin, you will

2013-08-10 20:00:31 616

原创 hdu 4331 Image Recognition

DescriptionNow there is an image recognition problem for you. Now you are given an image which is a N * N matrix and there are only 0s and 1s in the matrix. And we are interested in the squares in w

2013-08-09 16:39:34 497

原创 hdu 4334 Trouble

Problem DescriptionHassan is in trouble. His mathematics teacher has given him a very difficult problem called 5-sum. Please help him.The 5-sum problem is defined as follows: Given 5 sets S_1,...,

2013-08-08 14:57:51 448

原创 hdu 4337 King Arthur's Knights(dfs)

Problem DescriptionI am the bone of my sword. Steel is my body, and the fire is my blood.- from Fate / Stay NightYou must have known the legend of King Arthur and his knights of the round table.

2013-08-07 23:10:56 501

空空如也

空空如也

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

TA关注的人

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