码迷,mamicode.com
首页 > 其他好文 > 详细

Alphabet Cookies

时间:2015-04-21 22:47:50      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

1463: Alphabet Cookies

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

SubmitStatusWeb 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
****************************************************************/

Alphabet Cookies

标签:

原文地址:http://blog.csdn.net/zuguodexiaoguoabc/article/details/45175281

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!