zoukankan      html  css  js  c++  java
  • 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;
    }
    


  • 相关阅读:
    HDoj-2072-字数
    hibou 主界面自己侧滑的定义
    Android得到一个闹钟在第三方
    UILabel,UITextField 以及UIButton应用
    推荐几个好文章
    半年后,我还在路上。
    NGUI 3.5过程(三)Button button
    OpenGL研究2.0 计算圆
    CF 444A(DZY Loves Physics-低密度脂蛋白诱导子图)
    美日高价进口中国非转基因大豆:不仅吃还做药
  • 原文地址:https://www.cnblogs.com/codeyuan/p/4254535.html
Copyright © 2011-2022 走看看