fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. void sol(){
  5. string s;
  6. cin >> s;
  7. int c = 0, ans = 0;
  8. for(char ch:s){
  9. if(ch == '1') c++;
  10. else ans += c;
  11. }
  12. cout << ans << "\n";
  13. }
  14. signed main(){
  15. ios_base::sync_with_stdio(false);
  16. cin.tie(NULL);
  17. cout.tie(NULL);
  18. int t = 1;
  19. cin >> t;
  20. while(t--){
  21. sol();
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5236KB
stdin
Standard input is empty
stdout
0