杭电OJ2064 汉诺塔3

在这里插入图片描述
在这里插入图片描述

#include <iostream>
#include <cstdio>
using namespace std;	
__int64 N;
__int64 hanoi(int n)
{  	if (n==1)  
		return 2;
	else{
		return (hanoi(n-1) * 3+2);  
	}
	  
}
int main(){	
	while(cin>>N){
		cout<<hanoi(N)<<endl;
	}
	
	return 0;
} 

发布了43 篇原创文章 · 获赞 0 · 访问量 572

猜你喜欢

转载自blog.csdn.net/weixin_45191675/article/details/104955960