#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
int t, sum, cnt;
string input;
cin >> t;
getchar();
while(t--){
cin >> input;
int sz = input.size();
sum = 0, cnt = 0;
for(int i = 0; i < sz; i ++){
if(input[i] == 'O')cnt++, sum += cnt;
else cnt = 0;
}
cout << sum << endl;
}
return 0;
}
#include <cstdio>
#include <string>
using namespace std;
int main(){
int t, sum, cnt;
string input;
cin >> t;
getchar();
while(t--){
cin >> input;
int sz = input.size();
sum = 0, cnt = 0;
for(int i = 0; i < sz; i ++){
if(input[i] == 'O')cnt++, sum += cnt;
else cnt = 0;
}
cout << sum << endl;
}
return 0;
}
No comments:
Post a Comment