10 条题解

  • 1
    @ 2025-11-30 14:53:15

    包AC,我老师教的,不对去找我老师

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

    信息

    ID
    1234
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    递交数
    437
    已通过
    170
    上传者