题目大意:由1~N的自然数组成一个环,这个环满足相邻的自然数和为素数,
输出所有的情况
思路:本来以为DFS会超时,结果N是小于等于20的,所以直接DFS搜索。DFS
中三个变量,当前数字为now,下一个相邻的数为next,找到N个数中第几个数
为x,如果相邻数相加不是素数,则不必搜下去。否则记录第x个数的结果为next。
如果满足n个数,且最后第N个数与1的和也为素数就输出结果。否则就标记下当前
元素,表示已经使用过,继续找第x+1个数字。最后清除标记。...
                            
                            
                                分类:
其他好文   时间:
2014-11-24 11:58:00   
                                阅读次数:
217
                             
                         
                    
                        
                            
                            
                                Alexandra and Prime Numbers
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 706    Accepted Submission(s): 247
Problem Description
...
                            
                            
                                分类:
其他好文   时间:
2014-11-24 10:12:14   
                                阅读次数:
137
                             
                         
                    
                        
                            
                            
                                How many prime numbers
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8205 Accepted Submission(s): 2642
 
Problem...
                            
                            
                                分类:
其他好文   时间:
2014-11-24 08:43:47   
                                阅读次数:
116
                             
                         
                    
                        
                            
                            
                                题目 1000: A+B ProblemTime Limit: 1 Sec Memory Limit: 5 MBSubmit: 10227 Solved: 6457[Submit][Status] Description Calculate a+b Input Two integer a,b (0>...
                            
                            
                                分类:
其他好文   时间:
2014-11-24 00:50:23   
                                阅读次数:
313
                             
                         
                    
                        
                            
                            
                                注意n=n这种情况// 1059.cpp : 定义控制台应用程序的入口点。//#include#include#include#includeusing namespace std;queue prime;vector > col;void printElem(const pair it){ ...
                            
                            
                                分类:
其他好文   时间:
2014-11-23 18:45:12   
                                阅读次数:
168
                             
                         
                    
                        
                            
                            
                                Sum of Consecutive Prime Numbers
Time Limit: 1000MS
 
Memory Limit: 65536K
Total Submissions: 19699
 
Accepted: 10801
Description
Some positive integers can be represen...
                            
                            
                                分类:
其他好文   时间:
2014-11-23 16:04:23   
                                阅读次数:
163
                             
                         
                    
                        
                            
                            
                                import randomimport mathm=int(raw_input("Please input the Number of Times:"))#Then Output n=10~10^mn=1for j in xrange(m): n=n*10 Total=0 for i in x...
                            
                            
                                分类:
编程语言   时间:
2014-11-23 13:03:42   
                                阅读次数:
211
                             
                         
                    
                        
                            
                            
                                Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionAlexandra has a little ....
                            
                            
                                分类:
其他好文   时间:
2014-11-23 12:56:30   
                                阅读次数:
268
                             
                         
                    
                        
                            
                            
                                题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5108这个题目开始想错了,开始我用素数筛选法把1000000内的素数全找出来,大于1000000的数单独判断因为大于1000000得数只有100个,结果也超时,看超时代码#include#include#i...
                            
                            
                                分类:
其他好文   时间:
2014-11-23 11:45:16   
                                阅读次数:
228
                             
                         
                    
                        
                            
                            
                                Problem Description
Alexandra has a little brother. He is new to programming. One day he is solving the following problem: Given an positive integer N, judge whether N is prime.
The problem above is...
                            
                            
                                分类:
其他好文   时间:
2014-11-23 09:26:35   
                                阅读次数:
240