Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
必须ac(openjudge题解常客)#include<iostream> #include<cstring> using namespace std; const int N=13; int Hanoi_three[N]; int Hanoi_four[N]; int main() { memset(Hanoi_four,0x3f,sizeof Hanoi_four); Hanoi_four[1]=1; for(int n=2;n<=12;n++) { for(int i=1;i<=n;i++) { Hanoi_three[n]=2*Hanoi_four[n-i]+(1<<i)-1; Hanoi_four[n]=min(Hanoi_four[n],Hanoi_three[n]); } } for(int i=1;i<=12;i++) { cout<<Hanoi_four[i]<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator