首页 > 其他 > 详细

Codeforces Round #230 (Div. 2) 解题报告

时间:2014-02-20 07:18:16      阅读:411      评论:0      收藏:0      [点我收藏+]

Problem A. Nineteen

思路: 除了首位像连的n,其他的字母不能共用nineteenineteen。所以可以扫描一遍所有的字符串将出现次数保存到hash数组,n的次数(n - 1) / 2,e为e / 3。最小值就是min(i, e / 3, t , (n - 1) / 2)。

bubuko.com,布布扣
#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;
}
View Code

Codeforces Round #230 (Div. 2) 解题报告

原文:http://www.cnblogs.com/fripside/p/3556548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!