fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--)
  8. {
  9. string s;
  10. cin >> s;
  11. int n = s.size();
  12. int r=0,c=0;
  13. for(int i=n-1;i>=0;i--)
  14. {
  15. if((s[i]-'0') > 0 )
  16. {
  17. r = i;
  18. break;
  19. }
  20. }
  21. for(int i=0;i<r;i++)
  22. {
  23. if(s[i]=='0')
  24. {
  25. c++;
  26. }
  27. }
  28. int m = n-(n-1)+c ;
  29. cout << m << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5316KB
stdin
4
666
13700
102030
7
stdout
1
1
3
1