Codeforces Round #230 (Div. 2) problem A(小算数)
来源:互联网 发布:linux版本 编辑:程序博客网 时间:2024/04/29 20:37
题目链接:点击打开链接
题目分析:求一串字符中nineteen的个数
注意:n,i,t,e的数量关系
#include<cstdio>#include<algorithm>#include<cstdlib>#include<cstring>#include<cmath>using namespace std;char str[105];int length;int find (char c)//统计字符c出现的次数{ int count=0; for(int i=0;i<length;i++) { if(str[i]==c) count++; }return count;}int solve(){ int ans=0; int n=find('n'),i=find('i'),e=find('e'),t=find('t'); t=i=min(i,t); if(e>=i*3)//数量关系 { if(n>=2*i+1) return i; else return (n-1)/2; } else { return min(e/3,(n-1)/2); } return 0;}int main(){ while(scanf("%s",str)!=EOF) { length=strlen(str); printf("%d\n",solve()); } return 0;}
0 0
- Codeforces Round #230 (Div. 2) problem A(小算数)
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #324 (Div. 2) PROBLEM A
- Codeforces Round #363 (Div. 2), problem: (A)
- Codeforces Round #401 (Div. 2), problem: (A)
- Codeforces Round #221 (Div. 2) (Problem 376A~C)
- Codeforces Round #FF (Div. 2) Problem A DZY Loves Hash
- Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash
- contest: Codeforces Round #301 (Div. 2), problem: (A) Combination Lock
- Codeforces Round #295 (Div. 2), problem: (A) Pangram
- contest: Codeforces Round #303 (Div. 2), problem: (A) Toy Cars
- Codeforces Round #298 (Div. 2), problem: (A) Exam
- Codeforces Round #305 (Div. 2), problem: (A) Mike and Fax
- Codeforces Round #306 (Div. 2), problem: (A) Two Substrings
- Codeforces Round #320 (Div. 2)C. A Problem about Polyline
- Codeforces Round #320 (Div. 2) C. A Problem about Polyline
- Codeforces Round #320 (Div. 2) C - A Problem about Polyline
- Codeforces Round #320 (Div. 2) C - A Problem about Polyline
- Jquery中的层次选择器与find()的区别
- 聊聊Memcached的应用
- Andoird onStartCommand()
- use matlab engine
- Android高手进阶教程(五)之----Android 中LayoutInflater的使用!
- Codeforces Round #230 (Div. 2) problem A(小算数)
- u-boot Makefile -- make xxx_config
- 应该知道的几个Linux技巧
- 关于引用形参的解释
- itpp
- 点击显示指定元素,隐藏其他同辈元素
- C++ 改善程序与设计的做法
- 深入学习android之AlarmManager
- Delta3D 消息创建、注册、转发流程