fork(3) download
  1. /*
  2.  *
  3.  */
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. #define ll long long
  7. #define int long long
  8. #define el '\n'
  9. #define all(v) v.begin(), v.end()
  10. const int mod = 1000000000 + 7, OO = 0x3f3f3f3f;
  11. const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
  12. const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
  13. const char di[] = {'U', 'R', 'L', 'D'};
  14.  
  15. void solve() {
  16.  
  17. string s;
  18. cin >> s;
  19. int cnt = 0;
  20. int lastDigit = 0;
  21. for (int i = 0; i < s.size(); ++i) {
  22. if (s[i] == '0') cnt++;
  23. else lastDigit = i + 1;
  24.  
  25. }
  26. int n = s.size();
  27. int digits = n - cnt - 1;
  28. int zeroRemoved = s.size() - lastDigit;
  29. cout << zeroRemoved + digits << el;
  30.  
  31. }
  32.  
  33.  
  34. int32_t main() {
  35. ios_base::sync_with_stdio(false);
  36. cout.tie(nullptr), cin.tie(nullptr);
  37.  
  38. // if(fopen("in.txt", "r")){
  39. // freopen("in.txt", "r", stdin);
  40. // freopen("out.txt", "w", stdout);
  41. // }
  42.  
  43. int tt = 1;
  44. cin >> tt;
  45. while (tt--) {
  46. solve();
  47. }
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
-1