摘要:
View Code #include"iostream"using namespace std;int k=0;void hanoi(int m , char a ,char b, char c){ if(m==1) { k++; printf("%c->%c ",a , c); return; } hanoi(m-1, a, c , b); printf("%c->%c ",a , c); k++; hanoi(m-1 , b, a, c);}int main(){ int n; char x,y,z; while(ci 阅读全文
posted @ 2011-05-10 20:25
聊聊IT那些事
阅读(177)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2553Nqueen问题#include"iostream"using namespace std;int n;int a[20];int b[20];int c;bool Panduan(int x){ for(int i=0; i<x; i++) { if( (a[x]-a[i])==0 || (abs(a[x]-a[i])-abs(x-i))==0 ) return false; //关键点 } return true;}void dfs(int y ,int z){ for(i 阅读全文
posted @ 2011-05-10 20:05
聊聊IT那些事
阅读(432)
评论(0)
推荐(0)
摘要:
View Code #include"iostream"using namespace std;int a[1001],b[1001];int used[1001];int n;int i,j,q,t;void Init(){ for(i=1;i<40;i++) b[i]=1; for(i=2;i<40;i++) { for(j=2;j<40;j++) b[i*j]=0; }}void dfs(int x, int y){ if(y == n) { if( b[x+1] ) { a[n]=x; cout<<"1 "; for 阅读全文
posted @ 2011-05-10 16:29
聊聊IT那些事
阅读(336)
评论(0)
推荐(0)

浙公网安备 33010602011771号