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.

I_give_up | 241 |

maggiiiii | 143 |

makeitdonesolo | 140 |

lost_found | 128 |

abhithakur588 | 119 |

Bishnu Dev Panda | 777 |

I_give_up | 552 |

okayboss | 551 |

yk12 | 514 |

makeitdonesolo | 480 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.