答案

徐逸昊  •  2年前


  • include

    include

    using namespace std; bool f(string a,string b){ if(a==b){

    return true;
    

    }else if(a.size()==b.size()&&a.size()%2==0&&b.size()%2==0){

    string a1=a.substr(0,a.size()/2);
    string a2=a.substr(a.size()/2,a.size());
    string b1=b.substr(0,b.size()/2);
    string b2=a.substr(b.size()/2,b.size());
    return f(a1,b1)&&f(a2,b2)||f(a1,b2)&&f(a2,b1);
    

    }else{

    return false;
    

    } } int main(){ string a,b; cin>>a>>b; if (f(a,b)==true){ cout<<"YES"; }else{

    cout<<"NO";
    

    } return 0; }


评论: