标签:
No 2
#include<iostream> #include<cstring> #include<string> #include<cmath> #include<map> #include<queue> #include<cstdio> #include<vector> #include<algorithm> using namespace std; const int maxn=1000005; const int inf=210000; int a[maxn];//shop的哈希表 int b[maxn];//eva的哈希表 char shop[maxn]; char eva[maxn]; int main() { scanf("%s%s",shop,eva); int lena=strlen(shop); int lenb=strlen(eva); for(int i=0;i<lena;i++)a[shop[i]]++; for(int i=0;i<lenb;i++)b[eva[i]]++; int ans=0; for(int i=0;i<300;i++)if(b[i]!=0) { if(b[i]>a[i])ans+=b[i]-a[i]; } if(ans!=0) printf("No %d\n",ans); else printf("Yes %d\n",lena-lenb); }
1092. To Buy or Not to Buy (20)建立查询表,或者叫哈希表
标签:
原文地址:http://blog.csdn.net/u013167299/article/details/44263639