上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页
摘要: 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 and tel 阅读全文
posted @ 2012-03-04 18:38 狸の舞 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 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 the i+K 阅读全文
posted @ 2012-03-04 18:35 狸の舞 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1850Sample Output19210处理回溯问题,以及要在循环输入之前进行筛。View Code 1 #include<stdio.h> 2 #include<stdlib. 阅读全文
posted @ 2012-03-04 18:31 狸の舞 阅读(174) 评论(0) 推荐(0) 编辑
摘要: DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1.Inputn (0 < n < 20).OutputThe output format is shown 阅读全文
posted @ 2012-02-28 21:55 狸の舞 阅读(173) 评论(0) 推荐(0) 编辑
摘要: qsort各种强大啊~~写的也简单~~好喜欢它~~开心哦~~qsort及其用法函数原型void qsort(void *base, size_t num, size_t width, int (__cdecl *compare )(const void *elem1, const void *elem2 ) ); 大概的意思是,第一个参数指明了要排序的数组(比如:程序中的num),第二个参数给出了数组的大小(qsort没有足够的智力预知你传给它的数组的实际大小),第三个参数给出了数组中每个元素以字节为单位的大小。最后那个长长的家伙,给出了排序时比较元素的方式..再给一个例子:int a[n]; 阅读全文
posted @ 2012-02-28 20:13 狸の舞 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 今天李立教我们DFS,虽然以前就懂了那些思想,不过代码一直没有实践过,今天看了李立敲,终于 明白了DFS该怎么做,现在在研究BFS了……下面介绍一下我的DFS吧。首先,申请二维数组,输入那些数据,如果遇到要搜的,就进入DFS函数,然后进行深入的搜索,运用递归来实现,在递归之前,我们首先必须进行一个判断,看看是否搜索越界,如果没有越界,则进行进一步搜索(开始递归)。主要的代码:遇到第一个要搜索的东西的时候,进入DFS函数:View Code for( int i = 0; i < n; i++ ) { for( int j = 0; j < m;... 阅读全文
posted @ 2012-02-27 22:20 狸の舞 阅读(194) 评论(0) 推荐(1) 编辑
摘要: 1.带for循环的:View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int m; 5 int deal( int n ) 6 { 7 8 if( n == 1 ) 9 {10 for( int i = 0; i <= (m-n); i++ )11 printf( " " );12 printf( "*\n" );13 }14 else15 {16 for( int i =... 阅读全文
posted @ 2012-02-24 22:26 狸の舞 阅读(374) 评论(0) 推荐(0) 编辑
摘要: 话说输入N, 表示1~n个数, 在输入m,表示要删除的数。代码如下:View Code 1 #include <stdio.h> 2 #include <malloc.h> 3 #define LEN sizeof(struct student) 4 struct student 5 { 6 int num; 7 struct student *next; 8 }; 9 int main()10 {11 struct student *head,*p1,*p2;12 int i,m;13 scanf( "%d", &m );14 h... 阅读全文
posted @ 2012-02-21 21:16 狸の舞 阅读(273) 评论(0) 推荐(0) 编辑
摘要: A + B Problem IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 99134 Accepted Submission(s): 18806Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line o 阅读全文
posted @ 2012-02-20 16:59 狸の舞 阅读(223) 评论(0) 推荐(0) 编辑
摘要: The sum problemTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7877 Accepted Submission(s): 2422Problem DescriptionGiven a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M.InputI 阅读全文
posted @ 2012-02-16 19:11 狸の舞 阅读(357) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页