CF - 408 - B. Garland
来源:互联网 发布:零基础学javascript 编辑:程序博客网 时间:2024/05/18 17:23
题意:给两个由小写字母组成的字符串,长度分别为n,m (1 <= n, m <= 1000),代表有n张纸,一个要做成的m的花环,每个字符串的每个不一样的小写字母代表一种颜色,问最多能用多少张纸做成符合要求的花环,纸可以裁剪。
题目链接:http://codeforces.com/problemset/problem/408/B
——>>起床秒一题。。
统计字母出现的次数。。扫描26个字母的出现次数,判断一下。。
#include <cstdio>#include <cstring>using namespace std;const int maxn = 1000 + 10;const int al_maxn = 26 + 5;char s[maxn], t[maxn];int scnt[al_maxn], tcnt[al_maxn];int main(){ while(scanf("%s%s", s, t) == 2) { int slen = strlen(s); int tlen = strlen(t); memset(scnt, 0, sizeof(scnt)); memset(tcnt, 0, sizeof(tcnt)); for(int i = 0; i < slen; i++) scnt[s[i]-'a']++; for(int i = 0; i < tlen; i++) tcnt[t[i]-'a']++; int Max_area = 0; bool ok = true; for(int i = 0; i < 26; i++) { if(!tcnt[i]) continue; if(!scnt[i] && tcnt[i]) ok = false; if(scnt[i] > tcnt[i]) Max_area += tcnt[i]; else Max_area += scnt[i]; } ok ? printf("%d\n", Max_area) : puts("-1"); } return 0;}
0 0
- CF - 408 - B. Garland
- cf——B. Garland
- CF#239 B题 Garland
- cf 758 B. Blown Garland模拟
- codeforces 408B Garland
- Codeforence 408 B. Garland
- CF:Garland
- code forces 408B Garland
- CF-Codeforces Round #392 (Div. 2)-B-Blown Garland
- cf——B. Garland (桶排思想)
- B. Garland
- codeores--B. Garland--3.30
- B. Blown Garland
- 【CodeForce #239 Div2】408B——Garland
- 【codeforces 758B】Blown Garland
- Codeforces #392 B. Blown Garland
- Codeforces 758B-Blown Garland
- CodeForces 758B Blown Garland
- linux kernel goodness计算分析
- mysql的安装过程
- [Android]应用语言切换的三种方法
- MongoDB MapReduce 性能提升20倍的优化宝典
- 可扩展Web架构与分布式系统
- CF - 408 - B. Garland
- ubuntu 内核管理命令(简单)
- Apache Thrift - 可伸缩的跨语言服务开发框架
- mysql重装过程细节与mysql常见现的错误
- win7 MySQL完全卸载
- 4.控制结构
- 黑马程序员---java的IO系统学习总结
- 卷积的定义和例子
- Java NIO原理 图文分析及代码实现