1092 To Buy or Not to Buy (20 分)

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

分析:散列,水题
 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-25-20.31.15
 * Description : A1092
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 #include<unordered_map>
 using namespace std;
 unordered_map<char,int> mp;
 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     string a,b;
     cin>>a>>b;
     int len1=a.size();
     int len2=b.size();
     ;i<len1;i++){
         mp[a[i]]++;
     }
     ;
     ;i<len2;i++){
         ){
             mp[b[i]]--;
         }
         else{
             result++;
         }
     }
     ){
         printf("No %d",result);
     }
     else{
         printf("Yes %d",len1-len2);
     }
     ;
 }

1092 To Buy or Not to Buy (20 分)的更多相关文章

  1. pat 1092 To Buy or Not to Buy(20 分)

    1092 To Buy or Not to Buy(20 分) Eva would like to make a string of beads with her favorite colors so ...

  2. PAT 1092 To Buy or Not to Buy

    1092 To Buy or Not to Buy (20 分)   Eva would like to make a string of beads with her favorite colors ...

  3. poj1092. To Buy or Not to Buy (20)

    1092. To Buy or Not to Buy (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  4. PAT1092:To Buy or Not to Buy

    1092. To Buy or Not to Buy (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  5. PAT_A1092#To Buy or Not to Buy

    Source: PAT A1092 To Buy or Not to Buy (20 分) Description: Eva would like to make a string of beads ...

  6. PAT 乙级 1092 最好吃的月饼 (20 分)

    1092 最好吃的月饼 (20 分) 月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种. 若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出 ...

  7. PAT乙级:1092 最好吃的月饼 (20分)

    PAT乙级:1092 最好吃的月饼 (20分) 题干 月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种. 若想评比出一种"最好吃"的月饼,那势必在吃货界引发一场腥风 ...

  8. PAT 甲级 1011 World Cup Betting (20)(20 分)

    1011 World Cup Betting (20)(20 分)提问 With the 2010 FIFA World Cup running, football fans the world ov ...

  9. 1011 World Cup Betting (20 分)

    1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over wer ...

随机推荐

  1. L1-017 到底有多二

    一个整数“犯二的程度”定义为该数字中包含2的个数与其位数的比值.如果这个数是负数,则程度增加0.5倍:如果还是个偶数,则再增加1倍.例如数字-13142223336是个11位数,其中有3个2,并且是负 ...

  2. 会话跟踪session

    会话跟踪 HTTP是“无状态”协议:客户程序每次读取Web页面,都打开到web服务器的单独的连接,而且,服务器也不自动维护客户的上下文信息.类似客户决定结账时,如何确定之前创建的购物车中哪个属于此客户 ...

  3. Android Studio打开React Native创建的项目

    1.点击 Import project 2.找到项目下android文件夹,选择build.gradle文件,open

  4. 背景 半透明问题 rgba + filter

    <html style=" background: violet;"><head><meta charset="utf-8"> ...

  5. mysql 试图

    关系型数据库中的数据是由一张一张的二维关系表所组成,简单的单表查询只需要遍历一个表,而复杂的多表查询需要将多个表连接起来进行查询任务.对于复杂的查询事件,每次查询都需要编写MySQL代码效率低下.为了 ...

  6. 关于epoll的IO模型是同步异步的一次纠结过程

    这篇文章的结论就是epoll属于同步非阻塞模型,这个东西貌似目前还是有争议,在新的2.6内核之后,epoll应该属于异步io的范围了,golang的高并发特性就是底层封装了epoll模型的函数,但也有 ...

  7. UI基础:UIScrollView、UIPageControl

    UIScrollView UIScrollView 是可以滚动的视图,UIView本身不能滚动,子类UIScrollView扩展了滚动方面的功能. UIScrollView 是所有滚动视图的基类.以后 ...

  8. 玩转TypeScript(3)--类型转换

    使用强类型变量常常需要从一种类型向另一种类型转换,通常使用ToString或ParseInt可以来实现一些简单的转换,但是有时候需要像.NET语言中那样将一种类型显示的转换为另一种类型,在TypeSc ...

  9. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object reference

    /********************************************************************************* * Caused by: java ...

  10. qwb的骚扰

    题目描述 自从学姐拒绝了qwb之后,qwb开始了疯狂的骚扰.qwb来到了一个公共电话亭,他摸摸口袋只有n元钱. 已知该公用电话的规则是,前3分钟一共收费x元(不到3分钟也要收x元),超过3分钟每分钟收 ...