Untitled
raw download clone
C
views 29
,
size 940 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]) return 1;
        }

    }
    if(((ar-al+1)%2 == 1)&&((br-bl+1)%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.