思路: 除了首位像连的n,其他的字母不能共用nineteenineteen。所以可以扫描一遍所有的字符串将出现次数保存到hash数组,n的次数(n - 1) / 2,e为e / 3。最小值就是min(i, e / 3, t , (n - 1) / 2)。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <cstdio> #include <algorithm> int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif char c; int h[256] = {0}; while (scanf("%c", &c) != EOF && c != '\n') { h[c]++; } int sum = h['e'] / 3; sum = std::min(sum, h['i']); sum = std::min(sum, h['t']); sum = std::min(sum, (h['n'] - 1) / 2); printf("%d\n", sum); return 0; }
总想把每一篇文章精雕细琢之后以完美的面貌示人,就像演员在演出前都要彩排,总想准备好之后再去展现精彩的一面,但人生的每一刻都是精彩的,就算现在还不完善也要发出来,作为自己一直在学习的一种见证。