1018. Binary Prefix Divisible By 5
题目
给定一个数值含有0和1的数组A,考虑N_i为数组A[0]-A[i]的子数组的值构成的一个二进制数字(数组从低到高分别为二进制的高位到低位)。
返回一个包含boolean值的list结果answer,如果N_i的结果能被5整除,那么answer[i]为true。
Example 1:
Input: [0,1,1]
Output: [true,false,false]
Explanation:
The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10. Only the first number is divisible by 5, so answer[0] is true.
Example 2:
Input: [1,1,1]
Output: [false,false,false]
Example 3:
Input: [0,1,1,1,1,1]
Output: [true,false,false,false,true,false]
Example 4:
Input: [1,1,1,0,1]
Output: [false,false,false,false,false]
Note:
1 <= A.length <= 30000
A[i] is 0 or 1