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. PyQt5编程:鼠标事件

    参考链接:https://www.cnblogs.com/zhuluqing/p/9028816.html 一.每个事件都被封装成相应的类: pyqt中,每个事件类型都被封装成相应的事件类,如鼠标事件 ...

  2. opencv-python教程学习系列10-颜色空间转换

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍颜色空间转换,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 系 ...

  3. ZOJ2401 Zipper 双塔式 DP(双塔DP)

    第二次遇到双塔DP,再写一下. (flag是为了避免memset多次导致的时间浪费) #include<cstdio> #include<cstdlib> #include&l ...

  4. Gym 101630(NEERC 17) D.Designing the Toy

    题目大意:给出三视图方向上分别能看到的正方形数a,b,c(1<=a,b,c<=100),在-100<=x,y,z<=100的范围内构造出满足情况的一种正方体的摆放方式 做法很简 ...

  5. 修改ThinkPHP缓存为Memcache的方法

    一般来说,ThinkPHP的默认缓存方式是以File文件方式实现的,运行时会在/Runtime/Temp 下生成很多的缓存文件. 有的情况下服务器装了memcached之后,需要将ThinkPHP的缓 ...

  6. USB速率识别

    低速设备D-上有一个1.5k欧的上拉电阻.高速和全速设别在D+上有一1.5k欧上拉电阻.连接后通过检测电压变化来了解设备是否为低速设别. 低速下:D+为“0”,D-为“1”是为“J”状态,“K”状态相 ...

  7. FTP文件服务器代码

    文件操作的核心代码: /// <summary> /// FTP文件信息类(帮助进行文件的上传于下载) /// </summary> [Serializable()] publ ...

  8. C#编程之IList<T>、List<T>、ArrayList、IList, ICollection、IEnumerable、IEnumerator、IQueryable 和 IEnumerable的区别

    额...今天看了半天Ilist<T>和List<T>的区别,然后惊奇的发现使用IList<T>还是List<T>对我的项目来说没有区别...  在C#中 ...

  9. DDD领域驱动设计 ---- 系列文章

    C#进阶系列——DDD领域驱动设计初探(七):Web层的搭建 C#进阶系列——DDD领域驱动设计初探(六):领域服务 C#进阶系列——DDD领域驱动设计初探(五):AutoMapper使用 C#进阶系 ...

  10. 根据日期计算星期几----蔡勒(Zeller)公式推导

    计算给定日期是星期几,好象是编程都会遇到的问题,最近论坛里也有人提到这个问题,并给出了一个公式:             W=   (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400 ...