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