BNU 225587 Death Knight Hero【水水签到记录代码】

链接:




C. Death Knight Hero

1000ms
1000ms
65536KB
64-bit integer IO format:  %lld      Java class name:  Main
Font Size:   

 

There once was a champion of WoW
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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值