Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
12392 A班-袁誉晏 汉诺塔的移动次数 C++ 通过 100 1 MS 260 KB 314 2025-07-11 14:26:19

Tests(1/1):


#include <bits/stdc++.h> using namespace std; int temp=0; void move(int n,char a,char b,char c) { if(n==0) { return; } else { move(n-1,a,b,c); temp++; move(n-1,b,a,c); } } int main() { int n; char a='A',b='B',c='C'; cin>>n; move(n,a,b,c); cout<<temp<<endl; return 0; }


测评信息: