Given an odd-digit-number N, you need to find whether the given number is a balanced-number or not. An odd digit number is called a balanced number if the sum of all digits to the left of the middle digit and the sum of all digits to the right of the middle digit is equal.

**Input:**

The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows, a single line of the input containing a positive integer N.

**Output:**

For each test-case, print 0 if the number is not balanced, and 1 if the number is balanced.

**Constraints:**

1<=T<=100

1<=N<=10^{20}

**Example:**

**Input:**

5

121

1234006

19091

12345

90988

**Output:**

1

1

1

0

0

**Explanation:**

For testcase 1: 121.

The number of digits of 121 is 3, i.e. odd digits. The middle digit is 2. LHS sum is 1, and RHS sum is 1.

Since the sums are equal, we output 1.

For testcase 2: 1234006.

The number of digits of 1234006. is 7, i.e. odd digits. The middle digit is 4. LHS sum is 1+2+3=6, and RHS sum is 0+0+6=6.

Since the sums are equal, we output 1.

Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

geetyadav | 82 |

yashrana1 | 74 |

AdityaRaj9 | 73 |

abuexshaitan | 56 |

Shashi Bhushan | 52 |

abducodes | 837 |

harshtyagi36 | 399 |

sandipbhaumik | 321 |

Akhil varma | 314 |

vamsikrishna55 | 304 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.