链接:
C. Death Knight Hero
1000ms
1000ms
65536KB
64-bit integer IO format:
%lld Java class name:
Main
Font Size:

Arthasdk the name he was bestowed
He Death Gripped you to his side
His Chains of Ice stopped your stride
And Obliterates made you say "OWW!"
But one day our hero got puzzled
His Death Grip totally fizzled
In his darkest despair
He could barely hear
"OMG NOOB u Chains of Iced than u Death Gripped"
Input
You are given a recording of the abilities our hero used in his battles.
The first line of input will contain a single integer n (1 <= n <= 100), the number of battles our hero played.
Then follow n lines each with a sequence of ki (1 <= ki <= 1000) characters, each of which are either 'C', 'D' or 'O'. These denote the sequence of abilities used by our hero in the i-th battle. 'C' is Chains of Ice, 'D' is Death Grip and 'O' is Obliterate.
Output
Output the number of battles our hero won, assuming he won each battle where he did not Chains of Ice immediately followed by Death Grip.
Sample Input
3 DCOOO DODOCD COD
Sample Output
2
code:
注意:
he won each battle where he did not Chains of Ice immediately followed by Death Grip
是 C 后面马上出现 D 就输,而不是 C 跟在 D 后面。。。。
/**
题意:给你一个数 N
下面给出 N 个字符串代表 Hero 每次战争使用的技能
如果这次赢,则这串字符中不会出现 “CD”连在一起的情况
问:N次战斗,能赢几场。。。
*/
#include<stdio.h>
#include<string.h>
const int maxn = 1000+10;
int n;
char str[maxn];
int main()
{
while(scanf("%d", &n) != EOF)
{
int ans = 0;
while(n--)
{
scanf("%s", str);
int len = strlen(str);
int flag = 1;
for(int i = 0; i < len-1; i++)
{
if(str[i] == 'C' && str[i+1] == 'D')
{
flag = 0; break;
}
}
if(flag) ans++;
}
printf("%d\n", ans);
}
return 0;
}