1513.cpp 382 B

1234567891011121314151617181920
  1. #include <string>
  2. int numSub(std::string s) {
  3. int count = 0;
  4. long ans = 0;
  5. int mod = 1e9+7;
  6. int n = s.length();
  7. for(int i = 0;i<n;i++){
  8. if(s[i] == '1'){
  9. count++;
  10. }
  11. if(s[i] == '0' || i == n-1){
  12. while (count != 0) {
  13. ans += count--;
  14. }
  15. }
  16. }
  17. return int(ans % mod);
  18. }
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。