汉诺塔②
要求不能总最左移到最右或者从最右移到最左。
//例题8.2汉诺塔②
long long hnt(long long x){
if (x==1)return 2;
return 3*hnt(x-1)+2;
}
int main(){
long long x;
while(cin>>x)cout<<hnt(x)<<endl;
return 0;
}
要求不能总最左移到最右或者从最右移到最左。
//例题8.2汉诺塔②
long long hnt(long long x){
if (x==1)return 2;
return 3*hnt(x-1)+2;
}
int main(){
long long x;
while(cin>>x)cout<<hnt(x)<<endl;
return 0;
}
相关推荐