ACM2014选拔 4076. Words Count
来源:互联网 发布:ssr linux 客户端配置 编辑:程序博客网 时间:2024/06/06 21:40
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.InputIn 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.OutputFor 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 Inputxxxxxyxxxxxxxxyy212yyyyyx3123Sample Output211500
Sample Output
304
#include<stdio.h>#include<string.h>using namespace std;int main(){char s[100000];int l=0;int t=0;int ans=0;while(scanf("%s",s)!=EOF){t=0;l=strlen(s);for(int i=0;i<l;i++){if(s[i]>='A'&&s[i]<='Z'){t++;continue;}if(s[i]>='a'&&s[i]<='z'){t++;continue;}if(s[i]>='0'&&s[i]<='9'){t++;continue;}if(t)//防止出现sakjdh,akdh的情况,这种情况下应该是2个单词,此时t就是判断逗号的{ans=ans++;t=0;}}if(t)ans++;//t=0;//printf("%d",ans);}printf("%d",ans);//system("pause");return 0;}
0 0
- ACM2014选拔 4076. Words Count
- TOj 4076.Words Count
- acm2014
- ACM2014
- count words
- HDU-ACM2014
- HDU ACM2014
- python之单词统计(words count)
- Count index of sequence of words
- Wrap persistent words count one line in print program
- [C]simple code of count input lines,words,chars
- 杭电ACM2014:青年歌手打分
- words
- words
- Words
- words
- Words
- words
- JSP和JS的区别
- Sqlite使用手册
- 2014.08.26 周二-jdbc定义-oracle基本操作
- Arraylist与linkedlist的区别
- UI类的继承图
- ACM2014选拔 4076. Words Count
- 写一个自己的listview
- strtus2关于No result defined for action and result
- Java线程面试题 Top 50
- nginx start/stop
- UILabel, UITextView 高度自适应
- 产生随机数图片
- 使用小技巧
- Non-blocking algorithm(非阻塞算法,非阻塞同步的算法实现)