class Ideone
{
static boolean checkEquals(int a[], int start, int length) {
if (length==2) {
return a[start]==a[start+1] && a[start]==a[0];
}
else
return checkEquals(a,start+0,length/2) && checkEquals(a,start+length/2,length/2);
}
{
int a[]={1,1,1,1,1,1,1,1};
System.
out.
println(checkEquals
(a,
0,
8)); }
}
Y2xhc3MgSWRlb25lCnsKIAoJc3RhdGljIGJvb2xlYW4gY2hlY2tFcXVhbHMoaW50IGFbXSwgaW50IHN0YXJ0LCBpbnQgbGVuZ3RoKSB7CiAJCVN5c3RlbS5vdXQucHJpbnRsbigiQ2FsbGVkIik7CgkJaWYgKGxlbmd0aD09MikgewoJCSAgcmV0dXJuIGFbc3RhcnRdPT1hW3N0YXJ0KzFdICYmIGFbc3RhcnRdPT1hWzBdOwoJICB9CgkJZWxzZQoJCSAgIHJldHVybiBjaGVja0VxdWFscyhhLHN0YXJ0KzAsbGVuZ3RoLzIpICYmIGNoZWNrRXF1YWxzKGEsc3RhcnQrbGVuZ3RoLzIsbGVuZ3RoLzIpOwoJCSAgIAogCgl9CiAKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludCBhW109ezEsMSwxLDEsMSwxLDEsMX07CgkJU3lzdGVtLm91dC5wcmludGxuKGNoZWNrRXF1YWxzKGEsMCw4KSk7Cgl9Cn0=