Alphabet Cookies

1463: Alphabet Cookies

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 72   Solved: 37

Submit Status Web Board

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 words length isnt 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

7ARDHPYPHAPPY6ARDHPYHAPPY

Sample Output

YesNo

HINT

Source

黑龙江省第八届大学生程序设计竞赛

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;
int main()
{
  int N,i,j,lena,lenb,jihao,flag[110];
  char a[110],b[110];
 while(scanf("%d",&N)!=EOF)
 {
     jihao=0;
     memset(flag,0,sizeof(flag));
     cin>>a>>b;
     lenb=strlen(b);
     lena=strlen(a);
     for(i=0;i<lenb;i++)//5
     {
         for(j=0;j<lena;j++)//7
         {
             if(b[i]==a[j] && !flag[j])
             {
                 flag[j]=1;
                 jihao++;
                 break;
             } 
         }
     }
     if(jihao==lenb)
         cout<<"Yes"<<endl;
     else
         cout<<"No"<<endl;  
 }
 return 0;
}
 
/**************************************************************
    Problem: 1463
    User: CuiHuiling
    Language: C++
    Result: Accepted
    Time:3 ms
    Memory:1328 kb
****************************************************************/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值