PAT Serie B is going to buy

Source: Internet
Author: User

Title Description
Little Red want to buy some beads to make a string of their favorite beads. The owner of the bead sells a lot of colorful beads, but refuses to sell any strings. So little Red want you to help judge, whether a bead contains all the beads they want?
If so, tell her how many extra beads there are, and if not, tell her how many beads are missing.
For convenience, we use characters in [0-9], [A-z], [A-z] range to represent colors. For example, Yrr8rry is a bead string that little red wants to make, so ppRYYGrrYBR2258 can buy it, because it contains all the beads she wants, and 8 more.
Required beads; ppRYYGrrYB225 cannot buy, because there is no black beads, and a red bead is missing.
Input Description:
Each input consists of 1 test cases. Each test case is given in 2 rows of the owner's bead string and Little red want to do the bead string, two strings are not more than 1000 beads.
Output Description:
If you can buy, output "Yes" in one line and how many extra beads are available, and if not, output "no" in a row and how many beads are missing. Separated by 1 spaces in between.
Input Example:
ppRYYGrrYBR2258
Yrr8rry
Output Example:
Yes 8
#include <iostream>#include<string>using namespacestd;intMain () {//freopen ("Input.txt", "R", stdin);    stringHong, sales; intMatch =0, failure =0; CIN>> Sales >>Hong; //cout << sales.length () << hong.length ();    intS_length =sales.length (); intH_length =hong.length ();  for(inti =0; i < h_length; i++){         for(intj =0; J < S_length; J + +){            if(Hong[i] = =Sales[j]) {Match++; //cout << hong[i] << Endl;SALES[J] ='*';//Replace the characters that have been successfully matched//cout << sales[j] << Endl;                 Break; }//else if (j = = s_length-1) {failure++;}        }    }        if(Match = =h_length) {cout<<"Yes"<< S_length-h_length; }Else{cout<<"No"<< H_length-match; }}

freopen ("Input.txt", "R", stdin), This sentence is very useful ah, no longer have to manually enter data.

PAT Serie B is going to buy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.