TOj 4076.Words Count

题目链接:http://acm.tju.edu.cn/toj/showp4076.html



4076.    Words Count
Time Limit: 1.0 Seconds    Memory Limit: 65536K
Total Runs: 306    Accepted Runs: 140



This task is very simply, give you an article, you should just output how many words there are.
The words may be split by any separator such as ',' and '.' and so on.
The words only contains letters or digit and its length is at least one.

Input

Only one case, may have a lot of lines.

Output

Output the number of words.

Sample Input

Give you two strings, which are combined by two kinds of char 'x' and 'y'.
In this task, the first string is always longer than the second string.
If the first string's length is L, and the second string's length is M, you can easily know that there will be L-M+1 substrings of the first string, whose length is the same as the second string.
In these substrings, you can change some 'x' to 'y' or 'y' to 'x', in order to make this string the same as the second string.
And of course, different string may need to change different number of chars to achieve this target.
Here, tmeteorj wants to know how many substring, which has the same size as the second string, can be changed to be the same as second string exactly by change K chars.
Since tmeteorj is a very boring man, he wants to ask you Q times of such boring question.
Of course you are not such boring, so you decide to write a program to answer those questions.
Input
In the first two lines, there will be two string.
Followed by a positive integer q, means tmeteorj has q questions.
There will be q positive integer, indicating the exactly change times in this question.
The program should be process to EOF.
Be careful, the length of the string will no longer than 100000, and the number of questions will no bigger than 10000.
Output
For each question, you should just output one line, indicates the number of different ways to make the second string be the substring of the first string.

To make problem simple, you can only change the first string.
Sample Input
xxxxxyxxxxxxxx
yy
2
1
2
yyyyy
x
3
1
2
3
Sample Output
2
11
5
0
0

Sample Output

304



Source: TJU Team Selection 2014 Round1



 数词,很简单,水题上代码。


#include <stdio.h>
#include <string.h>
using namespace std;
int main(){
	char word[100001];
	int t,length,count=0;
	while(~scanf("%s",word)){
		length=strlen(word);
		t=0;
		for(int i=0;i<length;i++){
			if( (word[i]>='A'&&word[i]<='Z') ||  (word[i]>='a'&&word[i]<='z') || (word[i]>='0'&&word[i]<='9')  ){
				t++;
				continue;
			}
			if(t){
			count++;
			t=0;
			}
		}
		if(t)
			count++;
		//printf("%d\n",count);
	}
	printf("%d\n",count);
} 


 


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值