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 1:

No 2

#include<stdio.h>
#include<string.h>
#include<math.h>
char a[1010],b[1010];
int c[200],d[200],e[200];
int main()
{
int i,j,l1,l2,s=0;
scanf("%s%s",a,b);
memset(c,0,sizeof(c));
memset(d,0,sizeof(d));
memset(e,0,sizeof(e));
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
c[b[i]]++;
}
for(i=0;i<l1;i++)
{
d[a[i]]++;
}
for(i=0;i<l2;i++)
{
if(c[b[i]]>d[b[i]]&&e[b[i]]==0)
{
s+=c[b[i]]-d[b[i]];
}
e[b[i]]=1;
}
if(s==0)
{
printf("Yes %d\n",l1-l2);
}
else
{
printf("No %d\n",s);
}
return 0;
}

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

  1. 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 s ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. PAT1092:To Buy or Not to Buy

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

  6. 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 ...

  7. PAT (Advanced Level) Practise - 1092. To Buy or Not to Buy (20)

    http://www.patest.cn/contests/pat-a-practise/1092 Eva would like to make a string of beads with her ...

  8. PAT Advanced 1092 To Buy or Not to Buy (20) [Hash散列]

    题目 Eva would like to make a string of beads with her favorite colors so she went to a small shop to ...

  9. PAT (Advanced Level) 1092. To Buy or Not to Buy (20)

    简单题. #include<cstdio> #include<cstring> ; char s1[maxn],s2[maxn]; ]; ]; int main() { sca ...

随机推荐

  1. 使用MonkeyTest对Android客户端进行压力测试 自动化代码

    1.monkey命令简介 Monkey是Android中的一个命令行工具,可以运行在模拟器里或实际设备中.它向系统发送伪随机的用户事件流(如按键输入.触摸屏输入.手势输入等),实现对正在开发的应用程序 ...

  2. SASS使用总结

    简单用法: 变量 sass中可以定义变量,方便统一修改和维护. //sass style $fontStack: Helvetica, sans-serif; $primaryColor: #333; ...

  3. com学习 2015-10-16

    Com对象类似于C++类对象的概念, interface IX { virtral void fx()=0: } class CA:IX { virtual fx(){ printf("he ...

  4. Ossim应用体验视频

    Ossim体验视频 近期,我写的有关Ossim应用的系列文章网友们非常关注,这里对大家提出有一些问题我制作了高清的视频和截图发布到网站,以让更多的人了解这款开源安全平台.在年后出版的教程中会详细讲解o ...

  5. 委托delegate使用方法

    允许传递一个类A的方法m给另一个类B的对象,使得类B的对象能够调用这个方法m,说白了就是可以把方法当作参数传递. class Program { //delegate的使用方法一 public del ...

  6. ASP.NET的SEO: 服务器控件背后——SEO友好的Html和JavaScript

    本系列目录 假设你需要从一个页面转向其他页面,下面有很多种方式,你是如何选择的呢?你能清晰的说明理由么?         <%--链接的表现形式--%>        <asp:Hy ...

  7. 如何避免遭受HTTS中间人攻击

    先前为大家说明了如何对App的HTTPS通讯进行中间人攻击,听起来很吓人吧-表示若是使用手机的网银或购物等App,便有可能暴露在风险之中. 会发生HTTPS遭受拦截的主要原因是客户端的App未对服务器 ...

  8. C puzzles详解【16-20题】

    第十六题 The following is a small C program split across files. What do you expect the output to be, whe ...

  9. 在信号处理函数中调用longjmp

    错误情况及原因分析 前两天看APUE的时候,有个程序要自己制作一个sleep程序,结果在这个程序中就出现了在信号处理函数中调用longjmp函数的情况,结果就出现了错误,具体错误是啥呢,请参见下面这段 ...

  10. Linux 不挂载设备,获取设备的文件系统信息

    块设备挂载后,可以通过df 或者 mount命令查看设备的文件系统信息.然而,有时候需要在不挂载设备的情况下予以判断,此时可以使用如下的方法: (1)查看文件系统类型 命令: file -sL /de ...