CF#230 A题Nineteen

发布时间:2017-6-29 8:26:27 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"CF#230 A题Nineteen",主要涉及到CF#230 A题Nineteen方面的内容,对于CF#230 A题Nineteen感兴趣的同学可以参考一下。

Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters. Help her to find the maximum number of "nineteen"s that she can get in her string. Input The first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100. Output Print a single integer — the maximum number of "nineteen"s that she can get in her string. Sample test(s) input nniinneetteeeenn output 2 input nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii output 2 input nineteenineteen output 2 #include <stdio.h> #include <string.h> char s[102]; int main() { int i, j, x=100000, a[4]={0}, k; scanf("%s",s); k=strlen(s); for(i=0;i<k;i++) { if(s[i]=='n') a[0]++; else if(s[i]=='i') a[1]++; else if(s[i]=='e') a[2]++; else if(s[i]=='t') a[3]++; } a[0]=(a[0]-1)/2; a[1]=a[1]; a[2]=a[2]/3; a[3]=a[3]; for(i=0;i<4;i++) { if(x>a[i]) x=a[i]; } printf("%d\n",x); return 0; }

上一篇:【开发问题记录,持续更新..】
下一篇:getRequestURI()与getRequestURL()

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。