// UVa 1585 - Score #include <iostream> #include <string> using namespace std; int main() { int cases; for (cin >> cases; cases; cases--) { string line; cin >> line; int result = 0; int toTheLeft = 0; for (std::string::size_type i = 0; i < line.size(); ++i) { if (line[i] == 'O') { toTheLeft++; result += toTheLeft; } else { toTheLeft = 0; } } cout << result << endl; } return 0; }
No comments:
Post a Comment