Given a binary number, write a program that prints 1 if given binary number is a multiple of 3. Else prints 0. The given number can be big upto 2^100. It is recommended to finish the task using one traversal of input binary string.
Input:
The first line contains T denoting the number of testcases. Then follows description of testcases.
Each case contains a string containing 0's and 1's.
Output:
For each test case, output a 1 if string is multiple of 3, else 0.
Constraints:
1<=T<=100
1<=Length of Input String<=100
Example:
Input:
2
011
100
Output:
1
0
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.
codersanjeev | 66 |
snow_den_ | 60 |
BoggavarapuRamSaranSaiSrinivasGupta | 60 |
rajupraaa1234 | 53 |
SUZAKU | 49 |
mr_kksparrow | 433 |
manvirag982 | 258 |
snow_den_ | 232 |
arpit_anshuman | 228 |
SoumyaKaushik | 205 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |