Submission
Status:
[P-SSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Seng
Problemset: A.Six Zero
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-20 21:12:42
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define int long long
int count(int n){
if(n <= 1) return n;
return n+count(n-1);
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
int t;cin >> t;
while(t--){
string str;cin >> str;
map<int, int> m;//(index, จำนวน 0)
vector<int> idx;
for(int i = 0; i < str.size(); i++){
if(str[i] == '6'){
idx.push_back(i);
}
else if(!idx.empty() && str[i] == '0'){
for(auto e : idx) m[e]++;
}
}
int ans = 0;
if(!idx.empty()){
for(auto e : idx){
ans += count(m[e]-1)%M;
}
}
cout << ans << '\n';
}
}