//求解循环汉诺塔#include #include "vector"using namespace std;class Solution { public: vectorfn; vectorgn; Solution(): fn(10000000, 0), gn(10000000, 0) {} long long FN(int n) { //计算fn数组 if (n == 1) { fn[1] = 1; return fn[1]; } else { if (gn[n - 1] == 0) { //位置不存在 fn[n] = ((2 * GN(n - 1) + 1) % 1000000007); return fn[n]; } else { fn[n] = ((2 * gn[n - 1] + 1) % 1000000007); return fn[n]; } } } long long GN(int n) { //计算gn数组 if (n == 1) { gn[1] = 2; return gn[1]; } else { if (gn[n - 1] == 0 && fn[n - 1] == 0) { gn[n] = ((2 * GN(n - 1) + FN(n - 1) + 2) % 1000000007); return gn[n]; } else { gn[n] = ((2 * gn[n - 1] + fn[n - 1] + 2) % 1000000007); return gn[n]; } } } void LoopHanoi(int n) { cout }};int main() { Solution solution; int n; cin >> n; solution.LoopHanoi(n);}c