Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole pieces. Hence Eva must check whether a string in the shop contains all the beads she needs. She now comes to you for help: if the answer is Yes, please tell her the number of extra beads she has to buy; or if the answer is No, please tell her the number of beads missing from the string.

For the sake of simplicity, let's use the characters in the ranges [0-9], [a-z], and [A-Z] to represent the colors. For example, the 3rd string in Figure 1 is the one that Eva would like to make. Then the 1st string is okay since it contains all the necessary beads with 8 extra ones; yet the 2nd one is not since there is no black bead and one less red bead.

Figure 1

Input Specification:

Each input file contains one test case. Each case gives in two lines the strings of no more than 1000 beads which belong to the shop owner and Eva, respectively.

Output Specification:

For each test case, print your answer in one line. If the answer is Yes, then also output the number of extra beads Eva has to buy; or if the answer is No, then also output the number of beads missing from the string. There must be exactly 1 space between the answer and the number.

Sample Input 1:

ppRYYGrrYBR2258
YrR8RrY

Sample Output 1:

Yes 8

Sample Input 2:

ppRYYGrrYB225
YrR8RrY

Sample Output 2:

No 2

 #include <iostream>
#include <string>
using namespace std;
string sell, buy;
int nums[] = { }, res = ;//ASCALL表
int main()
{
cin >> sell >> buy;
for (auto s : sell)
nums[s]++;
for (auto s : buy)
{
if (nums[s] == )
res++;
else
nums[s]--;
}
if (res == )
cout << "Yes" << " " << (sell.size() - buy.size()) << endl;
else
cout << "No" << " " << res << endl;
return ;
}

PAT甲级——A1092 To Buy or Not to Buy【20】的更多相关文章

  1. 【PAT甲级】1116 Come on! Let's C (20分)

    题意: 输入一个正整数N(<=10000),接着依次输入N个学生的ID.输入一个正整数Q,接着询问Q次,每次输入一个学生的ID,如果这个学生的ID不出现在之前的排行榜上输出Are you kid ...

  2. 【PAT甲级】1069 The Black Hole of Numbers (20 分)

    题意: 输入一个四位的正整数N,输出每位数字降序排序后的四位数字减去升序排序后的四位数字等于的四位数字,如果数字全部相同或者结果为6174(黑洞循环数字)则停止. trick: 这道题一反常态的输入的 ...

  3. 【PAT甲级】1065 A+B and C (64bit) (20 分)(大数溢出)

    题意: 输入三个整数A,B,C(long long范围内),输出是否A+B>C. trick: 测试点2包括溢出的数据,判断一下是否溢出即可. AAAAAccepted code: #defin ...

  4. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  5. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

  6. PAT甲级题分类汇编——杂项

    本文为PAT甲级分类汇编系列文章. 集合.散列.数学.算法,这几类的题目都比较少,放到一起讲. 题号 标题 分数 大意 类型 1063 Set Similarity 25 集合相似度 集合 1067 ...

  7. PAT甲级题分类汇编——序言

    今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是 ...

  8. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  9. PAT 甲级真题题解(63-120)

    2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...

随机推荐

  1. Mysql优化-索引

    1. 索引的本质 MySQL官方对索引的定义为:索引是帮助MySQL高效获取数据的数据结构. 数据库查询是数据库的最主要功能之一.我们都希望查询数据的速度尽可能的快,因此 数据库系统的设计者会从查询算 ...

  2. swing 托盘

    直接上方法, 不过有些问题要注意,最后会说明! private void systemTray() { if (SystemTray.isSupported()) { // 判断系统是否支持托盘功能. ...

  3. win10 +Kinect V1 1414环境配置

    win10 +Kinect V1 1414环境配置 想起老Lab的机器人头顶的Kinect 安装准备 demo展示 人脸识别 照片不能够检测到人脸 可以去除背景 检测骨架 想起老Lab的机器人头顶的K ...

  4. Dos中转义符

    遇到个问题: java test R=<file> 11 22 按理说应该打印 R=<file> 11 22 但是,系统报错,写的是系统找不到指定文件. 是"< ...

  5. RAKsmart服务器受消费者青睐的原因

    随着互联网的快速发展,网站建设变得越来越重要,现在很多做外贸网站的都会选择美国服务器来建设网站,近年来RAKsmart服务器受到广大站长的欢迎,那RAKsmart服务器受消费者青睐的关键是什么呢. 1 ...

  6. MySQL学习 EXISTS的用法 转载

    比如在Northwind数据库中有一个查询为 SELECT c.CustomerId,CompanyName FROM Customers c WHERE EXISTS( SELECT OrderID ...

  7. 校园商铺-4店铺注册功能模块-1Dao层之更新店铺

    dao层增加更新店铺的方法 package com.csj2018.o2o.dao; import com.csj2018.o2o.entity.Shop; public interface Shop ...

  8. 框架前期准备篇之AutoFac常见用法总结 转载

    框架前期准备篇之AutoFac常见用法总结 一. 说在前面的话 凡是大约工作在两年以上的朋友们,或多或少都会接触到一些框架搭建方面的知识,只要一谈到框架搭建这个问题或者最佳用法这个问题,势必会引起一点 ...

  9. Vue .sync修饰符与$emit(update:xxx)写法问题

    在学习vue自定义事件的.sync修饰符实现改变数值时发现一个问题如下由于props的大小写命名:fatherNum,对应不同的$emit()会有不同的效果,具体如下: 使用.sync修饰符,即 // ...

  10. 第二十二篇:Spring简单定时任务

    背景:有些操作,不适合放在页面上让用户手动触发去执行,比如一些需要不断更新的数据(如统计数据)有些需要同步的数据,不需要非常实时,可以在固定的时间或者固定的频率执行同步 第一步:配置xml第二步:编写 ...