摘要: 简单DFS,需要注意的是最后的那个数加上一要是个素数。 代码如下:#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;int hash[25], rec[25], cnt;bool isprime( int x ){ if( x<= 1 ) return false; if( x== 2 ) return true; int lim= sqrt( x ); for( int i= 2; i<= lim; ++i 阅读全文
posted @ 2011-08-11 21:14 沐阳 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Accepted NecklaceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1027Accepted Submission(s): 407Problem DescriptionI have N precious stones, and plan to use K of them to make a necklace for my mother, but she won't accept a necklace which is to 阅读全文
posted @ 2011-08-11 20:38 沐阳 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 简单DFS,代码如下:#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;char word[10000][100];int hash[10000];void DFS( char *w, int cnt, int &ans ){ if( w[ strlen( w )- 1 ]== 'm' ) { ans= 1; return; } for( int i= 0; i< cnt; ++i ) { if( !hash[i]&& 阅读全文
posted @ 2011-08-11 16:02 沐阳 阅读(257) 评论(0) 推荐(0) 编辑