Submission

Status:
[PPPPPPPPPPP]

Score: 100

User: meme_boi2

Problemset: A.Six Zero

Language: cpp

Time: 0.012 second

Submitted On: 2025-02-28 13:37:10

//6-0
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
int MOD = 1e9+7;
void solve(string txt,int n0){
	int cnt = 0;
	for(int i = 0; i < txt.length(); i++){
		if(n0 < 2){
			break;
		} 
		else if(txt[i] == '0'){
			n0--;
			continue;
		}
		cnt = (cnt + ((n0 * (n0 - 1)) / 2) % MOD) % MOD;
	}
	cout << cnt << '\n';
}
int32_t main(){
	cin.tie(nullptr)->sync_with_stdio(0);
	int q;
	cin >> q;
	while(q--){
		int n0 = 0;
		string txt;
		cin >> txt;
		for(int i = 0; i < txt.length(); i++){
			if(txt[i] == '0') n0++;
		}
		solve(txt,n0);
	}
}