杭电hduoj 1996 汉诺塔VI

依旧水题

每个盘子都有3个位置可选,在每个柱子上的排列顺序是一定的,所以一旦选定就是一种方式,所以n个盘子就会产生3^n种情况,输出就可以了

#include<iostream>

#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
    long long n;
    cin>>n;
    cout<<fixed<<setprecision(0)<<pow(3,n)<<endl;
  }
}

猜你喜欢

转载自blog.csdn.net/vinacky/article/details/81878292