Submission
Status:
[PPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Seng
Problemset: A.Six Zero
Language: cpp
Time: 0.042 second
Submitted On: 2026-03-20 21:26:26
#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){
int n = m[e];
for(int i = 1; i <= n-1; i++) ans += i;
}
}
cout << ans%M << '\n';
}
}
// 0600600
// 6-> 2,