题意:给你2个数n m,从n变成m最少需要改变多少次。
其中:
1、n  m  都是4位数
2、每次只能改变n的一个位数(个位、十位、百位、千位),且每次改变后后的新数为素数
思路:搜索的变形题,这次我们要搜得方向是改变位数中的一位,然后往下搜,直到求出我们需要的那个解
#include
#include
#include
#include
#include
using namespac...
                            
                            
                                分类:
其他好文   时间:
2014-08-04 18:00:27   
                                阅读次数:
165
                             
                    
                        
                            
                            
                                Problem Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +...
                            
                            
                                分类:
其他好文   时间:
2014-08-04 17:52:47   
                                阅读次数:
187
                             
                    
                        
                            
                            
                                LinuxBash/Shell:[root@memshell]#catprime.sh
#!/bin/sh
#Printprimefrom1to100
for((i=1;i<=100;i++))
do
	if[$i-eq1];then
		continue
	fi
	flag=0
	for((j=2;j<i;j++))
	do
		a=$[$i%$j]
		if[$a-eq0];then
			flag=1
		fi
	done
	if[$flag-eq0];then
		echo$iispri..
                            
                            
                                分类:
其他好文   时间:
2014-08-04 14:42:08   
                                阅读次数:
257
                             
                    
                        
                            
                            
                                #include#includeusing namespace std;int main(){	cout << "n" << ' ' << "e" << endl;	cout << "-" << ' ' << "-----------" << endl;	cout << 0 << ' ' << 1 ...
                            
                            
                                分类:
其他好文   时间:
2014-08-04 14:00:57   
                                阅读次数:
170
                             
                    
                        
                            
                            
                                #include using namespace std;int a[30],n,used[40];int is_prime(int x){ for(int i=2;i>n) { memset(used,0,sizeof(used)) ; a[1]=1; used[1]...
                            
                            
                                分类:
其他好文   时间:
2014-08-04 13:27:17   
                                阅读次数:
280
                             
                    
                        
                            
                            
                                Problem FReverse PrimeInput:Standard InputOutput:Standard OutputThere are a few 7 digit positive numbers whose reverse number is a prime number and le...
                            
                            
                                分类:
其他好文   时间:
2014-08-03 23:07:36   
                                阅读次数:
469
                             
                    
                        
                            
                            
                                Prime Testhttp://poj.org/problem?id=1811 1 #include 2 #include 3 using namespace std; 4 typedef __int64 LL; 5 LL mulmod(LL a,LL b,LL c) { //ret=(...
                            
                            
                                分类:
其他好文   时间:
2014-08-03 20:18:15   
                                阅读次数:
245
                             
                    
                        
                            
                            
                                Prime PathTime Limit:1000MSMemory Limit:65536KTotal Submissions:11288Accepted:6398DescriptionThe ministers of the cabinet were quite upset by the mess...
                            
                            
                                分类:
其他好文   时间:
2014-08-03 17:52:35   
                                阅读次数:
225
                             
                    
                        
                            
                            
                                1 #include 2 #include 3 #include 4 #include //使用 assert.h 中的 assert 宏来限制非法函数的调用; 5 using namespace std; 6 7 // 判断是否为素数 8 int is_prime(int x) ...
                            
                            
                                分类:
其他好文   时间:
2014-08-01 12:53:11   
                                阅读次数:
245