Submission

Status:
[PPPPPPPPPPP]

Score: 100

User: Nathlol2

Problemset: A.Six Zero

Language: cpp

Time: 0.022 second

Submitted On: 2025-01-05 16:03:44

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll MOD = 1000000007;
ll nCr(ll n){
	n = (n - 1) * n;
	n /= 2;
	return n % MOD;
}

void solve(){
	string s;
	cin >> s;
	vector<int> six;
	int cur0 = 0;
	for(int i = s.size() - 1;i>=0;i--){
		if(s[i] == '0') cur0++;
		if(s[i] == '6'){
			six.pb(cur0);
		}
	}
	ll ans = 0;
	for(int i = 0;i<six.size();i++){
		ans += nCr(six[i]);
		ans %= MOD;
	}
	cout << ans << '\n';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	cin >> t;
	while(t--)
		solve();
}