随笔分类 - 搜索
摘要:Problem DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking
阅读全文
摘要:Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 2 #include 3 int map[210]; 4 int bfs(int a,int b); 5 int queue[10000]; 6 int mark[10000]; 7 int step[10000]; 8 int n; 9 int main()10 {11 int a,b;12 while(scanf("%d",&
阅读全文
摘要:Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determi
阅读全文
摘要:Problem DescriptionNow an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9. Each time, you can add or minus 1 to any digit. When add 1 to '9', the digit will change to be '1' and when minus 1 to '1'
阅读全文
摘要:Description平时不努力,考试得着急呐。传说中的BT监考老师竟然搬来了信号屏蔽工具,手机不管用啦有木有。不过这难不到大家,cxlove见证了同学们使用传统的作弊方式----传纸条,纸条得从A同学传到B同学处,在一个N*M的教室里,零散着坐着一些同学,监考老师游荡在教室某些位置,能否成功将纸条传到B同学处,且不被老师发现。每一次传纸条不能斜传,只能传给前后左右四个同学,监考老师的监视范围为相邻的八个位置,当纸条传到老师监视范围内就会被逮住了,纸条传到空位置处时传送失败。 帮cxlove计算下最少需要多少时间才能完成传纸条。Input多组测试数据第一行两个整数,N,M(1 #include
阅读全文
摘要:DescriptionDue to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 #include int visited[111][111],movex[8]={-1,-1,0,1,1,1,0,-1},movey[8]={0,-1,-1,-1,0,1,1,1},nx[100000],ny[100000]; char map[111][111]; void dfs(int i,int j);.
阅读全文
摘要:Description500年前,Jesse是我国最卓越的剑客。他英俊潇洒,而且机智过人^_^。突然有一天,Jesse心爱的公主被魔王困在了一个巨大的迷宫中。Jesse听说这个消息已经是两天以后了,他知道公主在迷宫中还能坚持T天,他急忙赶到迷宫,开始到处寻找公主的下落。 时间一点一点的过去,Jesse还是无法找到公主。最后当他找到公主的时候,美丽的公主已经死了。从此Jesse郁郁寡欢,茶饭不思,一年后追随公主而去了。T_T 500年后的今天,Jesse托梦给你,希望你帮他判断一下当年他是否有机会在给定的时间内找到公主。他会为你提供迷宫的地图以及所剩的时间T。请你判断他是否能救出心爱的公主。In
阅读全文
摘要:Description相传有一天,诸葛亮把将士们召集在一起,说:“你们中间不论谁,从1~1024中任意挑选一个整数,记在心里,我提十个问题,只要求回答'是'或'大于','小于'.十个问题全答完以后,我 就会‘算’出你心里记的那个数。”诸葛亮刚说完,一个谋士站起来说,他已经选好了一个数。诸葛亮问道:“你选的数大于512?”谋士答:“不是。”诸葛亮又接连向这,谋士提了九个问题,谋士一一作了回答。诸葛亮最后说:“你记的那个数是1。”谋士听了极为惊奇,因为这个数字真是他选的数。你知道诸葛亮是怎么妙算的吗?现在给你一个整数N,表示你要猜一个范围为【1,N】
阅读全文
摘要:Description居然有假币!!! 事情是这样的,现在猪肉涨了,但是农民的工资却不见涨啊,没钱怎么买猪肉啊。渊子这就去买猪肉,结果找来的零钱中有假币!!!可惜渊子一不小心把它混进了一堆真币里面去了。现在知道假币的重量比真币的质量要轻。给你一个天平,请用最快的时间把那个可恶的假币找出来。Input1≤n≤2^30,输入0结束程序。Output最少要称几次一定能把那个假币找出来。Sample Input3120Sample Output13思路:三分法一、 首先我们先来考虑最简单的问题1。为了方便叙述,把n个硬币按1,2,…,n顺次编号。二、 若n=3,把一号硬币放在天平左边、二号硬币放在天平
阅读全文