思路: 除了首位像连的n,其他的字母不能共用nineteenineteen。所以可以扫描一遍所有的字符串将出现次数保存到hash数组,n的次数(n - 1) / 2,e为e / 3。最小值就是min(i, e / 3, t , (n - 1) / 2)。
#include <cstdio>
#include <algorithm> int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
char c;
int h[] = {};
while (scanf("%c", &c) != EOF && c != '\n') {
h[c]++;
}
int sum = h['e'] / ;
sum = std::min(sum, h['i']);
sum = std::min(sum, h['t']);
sum = std::min(sum, (h['n'] - ) / );
printf("%d\n", sum);
return ;
}