HCPC2014校赛训练赛 4 A.Alphabet Cookies (3.16)

A.Alphabet Cookies
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 118 (62 users) Total Accepted: 74 (58 users) Special Judge: No
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

Author
BH


#include <iostream>
#include <string.h>
using namespace std;
int main()
{
    string a,b;int n,i;
    while(cin>>n)
    {
        int x[26],y=0;
        memset(x,0,sizeof(x));
        cin>>a;
        for(i=0;i<n;i++)x[a[i]-'A']++;
       // for(i=0;i<26;i++) cout<<x[i]<<" ";
        cin>>b;
        for(i=0;i<b.length();i++)
        {
            x[b[i]-'A']--;
            if(x[b[i]-'A']<0)
            {
                y=1;
                break;
            }
        }
           if(y==0)  cout<<"Yes"<<endl;
           else cout<<"No"<<endl;
    }
    return 0;
}

结果:
78099 A Accepted G++ 1ms 1144k 611B 2014-03-16 13:37:45

根据问题的描述,技术人员结合其他线索进行分析后,得出密码应该是字符串中子序列"ahcpc2023"的出现次数的除法结果。 子序列是由原字符串中的字符按照相对顺序构成的且不一定连续的序列。所以我们需要找到字符串中所有包含子序列"ahcpc2023"的子序列,并计算出现次数。然后将出现次数进行除法运算,得到密码。 为了更好地理解问题,我们可以举一个例子来说明。 假设待分析的字符串为"ahhpcc2023hchcpc2023ahcacpc2023",该字符串中"ahcpc2023"的子序列有"a", "h", "c", "p", "c", "2", "0", "2", "3", "ah", "ac", "ap", "a2", "a0", "a3", "hh", "hc", "2h", "hc", "hh", "cc", "c2", "c0", "c3", "hhc", "hhp", "hh2", "hh0", "hh3", "hcc", "hc2", "hc0", "hc3", "hhcc", "hhc2", "hhc0", "hhc3", "hcc2", "hcc0", "hcc3", "hc2h", "hc2c", "hc20", "hc2c", "hchh", "hchc", "hchh", "hcch", "hcc2", "hcc0", "hcc3", "hcpc", "hc2p", "hc0p", "hc3p", "ahcp", "ahc2", "ahc0", "ahc3", "hhcp", "hhc2", "hhc0", "hhc3", "hccp", "hc2p", "hc0p", "hc3p", "hhcpp", "hhc2p", "hhc0p", "hhc3p", "hc2cp", "hc0cp", "hc3cp", "hhccp", "hhc2p", "hhc0p", "hhc3p", "hcc2p", "hcc0p", "hcc3p", "hcpcp", "hc2cp", "hc0cp", "hc3cp", "hhcppp", "hhc2pp", "hhc0pp", "hhc3pp", "hc2cpp", "hc0cpp", "hc3cpp", "hhccpp", "hcc2pp", "hcc0pp", "hcc3pp", "hcpcpp", "hc2cpp", "hc0cpp", "hc3cpp", "ahcpp", "ahc2pp", "ahc0pp", "ahc3pp", "hhcppp", "hhc2pp", "hhc0pp", "hhc3pp", "hccppp", "hc2cpp", "hc0cpp", "hc3cpp", "hhcpppp", "hhc2ppp", "hhc0ppp", "hhc3ppp", "hc2cppp", "hc0cppp", "hc3cppp", "hhccppp", "hcc2ppp", "hcc0ppp", "hcc3ppp", "hcpcppp", "hc2cppp", "hc0cppp", "hc3cppp", "ahcppp", "ahc2ppp", "ahc0ppp", "ahc3ppp"。 我们可以看到,子序列"ahcpc2023"在字符串中共出现2次。因此,密码应为2。 总结来说,通过分析原字符串中子序列"ahcpc2023"的出现次数,我们可以得到密码。但具体的密码值需要根据实际分析的字符串来确定。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值