Untitled
raw download clone
TEXT
views 21
,
size 781 b
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char a[100005], b[100005];
int check(int al, int ar, int bl, int br);
int check(int al, int ar, int bl, int br){

for(int i=al-1; i<ar; i++){
    if(a[i]==b[i]){return 1;}   //比較a和b有沒有一樣
}
if(strlen(a)%2==1){return 0;}
else{
    int amid=(al+ar)/2;         //取a和b的中間
    int bmid=(bl+br)/2;
    if(check(al, amid, bl, bmid)){
       if(check(amid, ar, bmid, br)){return 1;}     //改變頭尾丟進函數檢查
    }
    else if(check(al, amid, bmid, br)){
       if(check(amid, ar, bl, bmid)){return 1;}
    }
    else{return 0;}
}
}
int main()
{

 scanf("%s %s", &a, &b);
 if(check(1,strlen(a), 1, strlen(b))){printf("Yes");}
 else{printf("No");}
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.