ZCMU 1462

1462: Alphabet Cookies

Description

Kitty likes cookies very much, and especially the alphabet cookies. Now, she get some alphabet cookies, and she wants to select some of them to spell some words.The easy task for you, is to determine that whether she can spell the word she wants.
Input

The input contains several test cases.Each test case contains an integer N ( 0 < N ≤ 100 ) in a line.And followed a line with N capital letters, means the cookies she has.Then the last line is a word with capital letters. And the word’s length isn’t more than N.

Output

One word for each test case. If she can spell the word by these letters, please output “Yes”, nor output “No”.

Sample Input

7
ARDHPYP
HAPPY
6
ARDHPY
HAPPY

Sample Output

Yes
No

HINT
简单题 储存判断就好了 好多种写法思路
Code:

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    char a[105],b[105];
    int x[30];
    while(~scanf("%d",&n))
    {
        memset(x,0,sizeof(x));
        scanf("%s %s",a,b);
        for(int i=0;i<strlen(a);i++)
            x[a[i]-'A']++;
        int f=1;
        for(int i=0;i<strlen(b);i++)
            x[b[i]-'A']--;
        for(int i=0;i<30;i++)
        {
            if(x[i]<0)
            {
                f=0;
                break;
            }
        }
        if(f)printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值