• Cf393A


    /*
    D - Nineteen
    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
    Submit
     
    Status
     
    Practice
     
    CodeForces 393A
    Description
    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 Input
    Input
    nniinneetteeeenn
    Output
    2
    Input
    nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii
    Output
    2
    Input
    nineteenineteen
    Output
    2
    By Grant Yuan
    2014.7.11*/
    #include<iostream>
    #include<stdio.h>
    
    #include<stdlib.h>
    #include<string.h>
    using namespace std;
    char a[102];
    char b[4]={'n','i','e','t'};
    int c[4];
    int main()
    {
       memset(c,0,sizeof(c));
       cin>>a;
       int l,t;
       l=strlen(a);
       //cout<<l<<endl;
       for(int i=0;i<l;i++)
          for(int j=0;j<4;j++)
            if(a[i]==b[j])
              c[j]++;
              //c[0]=c[0]/3;
              c[2]=c[2]/3;
        int min=c[0];
        for(int i=0;i<4;i++)
          if(c[i]<min)
            min=c[i];
           /* if(min==1)
               if(c[0]<3) min=0;
            else {if(min>1)
               //if(c[0]<3+(min-1))
               t=(c[0]-3)/2;
        if(t<min) min=t;}*/
        int j;
        if(min>0)
          if(c[0]<1+2*min){
             for(j=min;j>0;j--)
                {if(c[0]>=1+2*j)
                   break;}
                   min=j;}
        cout<<min<<endl;
        return 0;
    }
    


  • 相关阅读:
    集合框架学习笔记<二>
    Notepad++ Emmet安装方法教程
    vi 常用命令行
    iOS应用架构谈 view层的组织和调用方案
    搭建ssh框架项目(二)
    eclipse安装主题插件(Color Theme)
    eclipse安装properties插件
    Eclipse安装SVN插件
    搭建ssh框架项目(一)
    J2SE基础小结
  • 原文地址:https://www.cnblogs.com/codeyuan/p/4254535.html
Copyright © 2020-2023  润新知