随笔分类 -  搜索

摘要:Problem Description蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么这些牌也跟着一起移动,游戏的目的是将所有的牌按同一花色从小到大排好,为了简单起见,我们的游戏只有同一花色的10张牌,从A到10,且随机的在一行上展开,编号从1到10,把第i号上的牌移到第j号牌上,移动距离为abs(i-j),现在你要做的是求出完成游戏的最小移动距离。Input第一个输入数据是T,表示数据的组数。每组数据有一行,10个输入数据,数据的范围是[1,10],分别表示A到10,我们保证每组数 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(360) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go up Ki floor,i.e,you will go to 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(179) 评论(0) 推荐(0)
摘要:Description机器人要在一个矩形迷宫里行动(不能原地停留,只能走向上/下/左/右),每移动一格花费1个单位时间。迷宫有以下几种元素:【*】机器人的起点【#】墙。机器人不能走过这些格子【.】平地。机器人可以在上面自由行走【0-9】宝藏。当机器人走到此处会立刻获得该数字相应的宝藏,宝藏不会消失,可以反复获取(但不能停留)若机器人要恰好获得总和为x的宝藏,它最少需要多少时间?Input第一行输入任务数量T,接下来有T个任务每块第一行有两个整数, n(0 <100), m(0 < 100),表示迷宫有n+1行和m+1列接下来n行输入迷宫最后一行输入你要收集的宝藏的总价值x(x≤10 阅读全文
posted @ 2012-03-15 12:59 'wind 阅读(234) 评论(0) 推荐(0)
摘要:Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, E 阅读全文
posted @ 2012-03-15 12:58 'wind 阅读(171) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is a mountain near yifenfei’s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it.Now we know yifenfei have n spells, and the monster have m HP, when HP <= 0 meaning monster be killed. Yifenfei’s spells have different effect if 阅读全文
posted @ 2012-03-15 12:57 'wind 阅读(263) 评论(0) 推荐(0)
摘要:Problem DescriptionYou're in space.You want to get home. There are asteroids. You don't want to hit them. InputInput to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank 阅读全文
posted @ 2012-03-15 12:56 'wind 阅读(224) 评论(0) 推荐(0)
摘要:Problem DescriptionZty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solvea problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their rel 阅读全文
posted @ 2012-03-15 12:55 'wind 阅读(217) 评论(0) 推荐(0)
摘要:Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1850Sample Output19210code :View Code #include<stdio.h>#include<string.h>int tot 阅读全文
posted @ 2012-03-15 12:54 'wind 阅读(196) 评论(0) 推荐(0)
摘要:Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.Input测试数据有多组。每组有多行,每行一个单词,仅包括小写字母,是Harry所 阅读全文
posted @ 2012-03-15 12:53 'wind 阅读(181) 评论(0) 推荐(0)
摘要:DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of t 阅读全文
posted @ 2012-03-15 12:52 'wind 阅读(273) 评论(0) 推荐(0)
摘要:Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to save Angel. Their task is: approach Angel. We assume that "approach Angel 阅读全文
posted @ 2012-03-15 12:51 'wind 阅读(174) 评论(0) 推荐(0)
摘要:DescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from ano 阅读全文
posted @ 2012-03-15 12:50 'wind 阅读(187) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>int prime[40];int a[20];int vis[20];int n;int isprime(int n){ int i; for(i=2;i*i<=n;i++) if(n%i==0) return 0; return 1;}void dfs(int cur){ int i; if(cur==n&&prime[a[0]+a[n-1]]) //递归边界,最后一个数和第一个数和是质数 { for(i=0;i<n;i++... 阅读全文
posted @ 2012-03-15 12:49 'wind 阅读(135) 评论(0) 推荐(0)
摘要:DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。 阅读全文
posted @ 2012-03-15 12:46 'wind 阅读(141) 评论(0) 推荐(0)
摘要:迷宫问题Time Limit:1000MSMemory Limit:65536KTotal Submissions:3850Accepted:2226Description定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角 阅读全文
posted @ 2012-03-15 12:44 'wind 阅读(331) 评论(0) 推荐(0)
摘要:要求: 输入行数为n列数为m的迷宫,用‘s’表示起点,‘#’表示墙头,输出起点到各点的最短路。sample input:5 5s#....#....#..........#..sample output:0 0 8 9 101 0 7 0 92 0 6 0 83 4 5 6 74 5 0 7 8code:View Code #include<stdio.h> #include<string.h> int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0}; int q[100000]; int maze[200][200]; int vis[200][2 阅读全文
posted @ 2012-03-15 12:36 'wind 阅读(264) 评论(0) 推荐(0)
摘要:DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting 阅读全文
posted @ 2012-03-15 12:35 'wind 阅读(192) 评论(0) 推荐(0)
摘要:Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using s 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(173) 评论(0) 推荐(0)
摘要: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 adjacent tiles. But he can't move on red tiles, he can move only on black tiles.Write a program to count 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(252) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>int id,jd,k,t,m,n,f[8]={0,0,1,-1,1,-1,0,0};char s[8][8];void dfs(int i,int j,int c){ int p,ii,jj; if(i==id&&j==jd) { if(c==k) t=1; return; } for(p=0;p<4;p++) { ii=i+f[p]; jj=j+f[p+4]; if(... 阅读全文
posted @ 2012-03-15 12:33 'wind 阅读(192) 评论(0) 推荐(0)