Gotta Catch Em' All!_Codeforces
来源:互联网 发布:网络公开课网站 编辑:程序博客网 时间:2024/04/28 15:29
2017年2月5日23:20:31
这题 WA了两发,是因为, for循环中的判断条件成了,i<strlen(s) ,这样 每次循环都会 调用len函数 所以 应该先定义 一个变量等于strlen(s) 然后用常量作为循环条件 要谨记这个教训!
代码如下:
#include <stdio.h>#include <string.h>#define maxn 100001char s[maxn];int main(){ int n[8]={0}; scanf("%s",s); for(int i=0;s[i]!='\0';i++){ if(s[i]=='B'){ n[1]++; } if(s[i]=='u'){ n[2]++; } if(s[i]=='l'){ n[3]++; } if(s[i]=='b'){ n[4]++; } if(s[i]=='a'){ n[5]++; } if(s[i]=='s'){ n[6]++; } if(s[i]=='r'){ n[7]++; } } n[2]/=2; n[5]/=2; int num=maxn; for(int i=1;i<=7;i++){ if(n[i]<num){ num=n[i]; } } printf("%d\n",num); return 0;}
0 0
- Gotta Catch Em' All!_Codeforces
- codeforces757A. Gotta Catch Em' All!
- A. Gotta Catch Em' All!
- codeforces 757 A. Gotta Catch Em' All!
- Codeforces 757 Gotta Catch Em' All!
- 【codeforces 757A】Gotta Catch Em' All!
- Codeforces Round #391 -A. Gotta Catch Em' All!
- cf 757A Gotta Catch Em' All! (水题)
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) A. Gotta Catch Em' All!(水题)
- Catch all type exceptions programming Android
- gonna, gotta, wanna
- Codeforces Gym101246C:Explode 'Em All(DP + bitset)
- 【一句话博客】_CodeForces 55D Beautiful numbers
- em
- em
- EM
- EM
- EM
- 设计模式之命令模式
- LeetCode_389-Find the Difference
- php使用Iterator接口,逐行遍历文件
- Java语言中==和equals的区别详解
- 正方形共享存储器
- Gotta Catch Em' All!_Codeforces
- 1120. Friend Numbers
- C语言中如何添加背景音乐
- 删除了目录卸载或安装出现Invalid drive错误
- pom.xml详解
- C++Primer第五版 第十二章习题答案(21~30)
- linux下的hadoop配置 sbin/start-all.sh datanode守护进程启动失败----解决方案
- 【剑指Offer】把二叉树打印成多行
- Mysql 破坏root 账户 修复