codeforces--2014/2/20--A. Nineteen
来源:互联网 发布:遵义广电网络客服电话 编辑:程序博客网 时间:2024/05/16 08:06
Alice likes word "nineteen" very much. She has a strings 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.
The first line contains a non-empty string s, consisting only of lowercase English letters. The length of strings doesn't exceed 100.
Print a single integer — the maximum number of "nineteen"s that she can get in her string.
nniinneetteeeenn
2
nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
2
nineteenineteen
2
统计字母的个数,注意n是有重叠的
#include <stdio.h>#include <string.h>int main(){ int i , j , li , num_n = 0 , num_i = 0 , num_t = 0 , num_e = 0 ; char s[110] ; scanf("%s", s); li = strlen(s); for(i = 0 ; i < li ; i++) { if(s[i] =='n')num_n++; else if(s[i]=='i')num_i++; else if(s[i] == 't')num_t++; else if(s[i] == 'e') num_e++; } num_e = num_e / 3 ; li = num_e; if(num_i < li) li = num_i ; if(num_t < li) li = num_t ; if(li*3 - li + 1 > num_n) li = (num_n-1)/2 ; printf("%d\n", li);}
- codeforces--2014/2/20--A. Nineteen
- Codeforces Round #230 (Div. 2) A. Nineteen
- Codeforces Round #230 (Div. 2)A. Nineteen
- codeforces 393A Nineteen
- codeforces比赛题A. Nineteen,BThree matrices
- Codeforces 393A Nineteen(水题)
- CodeForce 393A Nineteen
- Nineteen Codeforence 393A
- CF 393A:Nineteen
- CF#230 A题Nineteen
- code forces 393A Nineteen
- Nineteen
- Nineteen
- codeforces Rockethon 2014 A
- codeforces 2A Winner
- CODEFORCES 2A-Winner
- codeforces 2A. Winner
- Codeforces 2A Winner
- 按地点授权过滤左列表
- arp断网攻击解决办法
- Ubuntu下面安装eclipse for c++
- 虚拟机下ubuntu上网
- HDU 1263 水果
- codeforces--2014/2/20--A. Nineteen
- AVAudioPlayerDemo
- ubuntu 安装 酷狗在线音乐桌面版
- hping的使用方式
- codeforces--2014/2/20--B. Three matrices
- Myeclipse 8.5 Preferences 下无tomcat
- Linux磁盘管理命令
- NMOS和PMOS
- ZOJ-1016