Last active
September 16, 2018 16:26
-
-
Save WindAzure/c8acd0f5715c960d16d4bac9c190eb02 to your computer and use it in GitHub Desktop.
UVa 1585
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| int main() | |
| { | |
| auto T = 0; | |
| int dp[100] = { 0 }; | |
| char testResult[100]; | |
| scanf("%d", &T); | |
| for (auto t = 0; t < T; t++) | |
| { | |
| scanf("%s", testResult); | |
| auto strLen = strlen(testResult); | |
| for (auto i = 0; i < strLen; i++) | |
| { | |
| dp[i] = (testResult[i] == 'O') ? 1 : 0; | |
| } | |
| auto result = 0; | |
| for (auto i = 1; i < strLen; i++) | |
| { | |
| if (testResult[i] == 'O') | |
| { | |
| dp[i] += dp[i - 1]; | |
| result += dp[i]; | |
| } | |
| } | |
| printf("%d\n", result + dp[0]); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment