Untitled
raw download clone
C
views 26
,
size 834 b
#include<stdio.h>
#include<string.h>

char a[100002],b[100002];

//ap,bp:小STRING的第一個位置

int str_cmp(int ap, int bp, int len)
{
     int i;
     for(i=0;i<len;i++)
     {
          if(a[ap+i]!=b[bp+i])break;
     }
     if(i==len)return 1;
     else return 0;
}

int Jonny(int ap,int bp,int len)
{
     int amid,bmid;
     if(str_cmp(ap,bp,len))
     {
          return 1;
     }
     else if (len%2==1)return 0;
     else
     {
          len/=2;
          amid=ap+len;
          bmid=bp+len;
          if(Jonny(ap,bp,len)&&Jonny(amid,bmid,len)||Jonny(ap,bmid,len)&&Jonny(amid,bp,len))return 1;
          else return 0;
     }
}

int main(void)
{
     scanf("%s",a);
     scanf("%s",b);
     if(Jonny(0,0,strlen(a)))printf("YES\n");
     else printf("NO\n");
     return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.