1 class Solution 2 { 3 public: 4 vector<bool> prefixesDivBy5(vector<int>& A) 5 { 6 vector<bool> v(A.size()); 7 int rnt = 0; 8 for(int i = 0; i< A.size();i ++) 9 { 10 if(A[i]==1) 11 { 12 if(rnt==0) 13 {rnt = 1;v[i] = false;} 14 else if(rnt==1) 15 {rnt = 3;v[i] = false;} 16 else if(rnt==2) 17 {rnt = 0;v[i] = true;} 18 else if(rnt==3) 19 {rnt = 2;v[i] = false;} 20 else if(rnt==4) 21 {rnt = 4;v[i] = false;} 22 } 23 else if(A[i]==0) 24 { 25 if(rnt==0) 26 {rnt = 0;v[i] = true;} 27 else if(rnt==1) 28 {rnt = 2;v[i] = false;} 29 else if(rnt==2) 30 {rnt = 4;v[i] = false;} 31 else if(rnt==3) 32 {rnt = 1;v[i] = false;} 33 else if(rnt==4) 34 {rnt = 3;v[i] = false;} 35 } 36 } 37 return v; 38 } 39 };
原文地址:https://www.cnblogs.com/Asurudo/p/10630798.html
时间: 2024-10-25 05:53:22