Untitled
raw download clone
C
views 56
,
size 948 b
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char a[100005];
char b[100005];
int f(char c, char d, int al, int ar, int bl, int br){
    int i, j;
    for(i=al;i<=ar;i++){          //判斷a b字串是否相等
        for(j=bl;j<=br;j++){
            if (a[i]!=b[j]) break;
        }
        if(a[i] == b[j]) return 1;
    }
    if(strlen(a)%2 == 1) return 0;
        else{
            int amid = (al+ar)/2;
            int bmid = (bl+br)/2;
            if (f(c, d, al, amid, bl, bmid) && f(c, d, amid, ar, bmid, br))
                return 1;
            else if (f(c, d, al, amid, bmid, br) && f(c, d, amid, ar, bl, bmid))
                return 1;
            else
                return 0;
        }
}
int main ( ){
    int i, len;
    scanf("%s%s", a, b);
    len = strlen(a);
    if(f(a, b, 0, len-1, 0, len-1))
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.