原题链接 考察模运算公式: (a + b) % n = (a % n + b % n) % n; 123456789101112class Solution {public: vector<bool> prefixesDivBy5(vector<int>& A) { int x = 0; vector<bool> ans; for(int i=0;i<A.size();i++) { x = ((x<<1)+A[i])%5; ans.push_back(x==0); } return ans; }};