DescriptionSpies use attributes to disguise themselves to make sure that they are not recognized. For example, when putting on sunglasses, a spy sudde...
分类:
其他好文 时间:
2015-04-18 23:28:23
阅读次数:
214
BFS学习总结
给你一个n*m的网格迷宫,迷宫中有些格子不能走,其他的格子都能走。然后给你起点与终点,问你从起点走到终点最少需要多少步?
上面的问题就是一个典型的BFS问题,对于这类问题来说,只要你掌握了这类问题的关键思想,其实他们都是可以用类似的思路来做的。建议先做两道BFS简单题,体会一下。
你可以把BFS问题想象成:从一个父亲(起点...
分类:
其他好文 时间:
2015-04-16 01:30:25
阅读次数:
222
转自:http://blog.sina.com.cn/s/blog_6635898a0100magq.html1.burnside定理,polya计数法 这个大家可以看brudildi的《组合数学》,那本书的这一章写的很详细也很容易理解。最好能完全看懂了,理解了再去做题,不要只记个公式。 *简单题:...
分类:
其他好文 时间:
2015-04-15 00:43:07
阅读次数:
190
Sequence oneProblem DescriptionSearch is important in the acm algorithm. When you want to solve a problem by using the search method, try...
分类:
其他好文 时间:
2015-04-13 20:44:52
阅读次数:
135
刚开始学c,还不了解,花了两个多真是写了书上的五个简单题,慢慢来吗!不积小流,无以成江河#include "stdio.h"void main(){ int c,n; scanf("%d",&n); c=n%2; if(c=0) printf("n is an even"); else prin.....
分类:
其他好文 时间:
2015-04-09 19:26:38
阅读次数:
152
简单题不解释, 维护一个进位即可public class Solution {
public int[] plusOne(int[] digits) {
int c = 1;
for(int i = digits.length - 1; i >=0; i --){
if(c == 0)break;
digits[i]...
分类:
其他好文 时间:
2015-04-06 17:20:23
阅读次数:
155
Problem Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩...
分类:
其他好文 时间:
2015-04-06 06:12:43
阅读次数:
184
给出一个数t,n,然后后面有n个数。问:从这n个数里面能不能挑出一些数,使得和为t,注意输出顺序。Sample Input4 6 4 3 2 2 1 1 5 3 2 1 1 400 12 50 50 50 50 50 50 25 25 25 25 25 25 0 0Sample OutputSums...
分类:
其他好文 时间:
2015-04-06 00:53:18
阅读次数:
298
题意:一只小狗要刚好在t时刻从起点都到终点,问可不可以。注意剪枝。 1 #include 2 #include 3 #include 4 using namespace std; 5 int maze[9][9]; 6 bool vis[9][9]; 7 int n,m,t; 8 bool ans;...
分类:
其他好文 时间:
2015-04-05 23:22:08
阅读次数:
186
一个电梯有n层,每一层有一个数k[i],和2个按钮,UP和DOWN,表示从这一层可以到达i+k[i] 或i-k[i] .给出a,b,问从a到b 最少需要按多少下按钮。直接bfs. 1 #include 2 #include 3 #include 4 using namespace std; 5 co...
分类:
其他好文 时间:
2015-04-05 15:58:51
阅读次数:
205