1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| class Solution { public: vector<bool> prefixesDivBy5(vector<int>& A) { vector<bool> ret; int res = 0; for(auto&&a:A){ res = res * 2 + a; res %= 10; if(res % 5 == 0){ ret.push_back(true); }else{ ret.push_back(false); } } return ret; } };
|