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;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章