8 条题解

  • 1
    @ 2023-6-5 17:41:16
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <vector>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include<cstring>
    #include <algorithm>
    #define LL long long
    const int N = 1e2 + 10;
    const int INF = 0x3f3f3f3f;
    using namespace std;
    int n ;
    void f(int n , char A , char B ,char C )
    {
    	if( n == 0 )
    	{
    		return; 
    	}
    	f( n - 1 , A , C , B );
    	cout << "Move " << A <<" to " << C << endl ;
    	f( n - 1 , B , A , C );
     } 
    int main()
    {
    	cin >> n ;
    	cout << pow(2,n) - 1 << endl ;
    	f( n , 'A' , 'B' , 'C' ); 
    	return 0;
    }
    
    

    信息

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