PAT (Advanced Level) 1092. To Buy or Not to Buy (20)
Posted Fighting Heart
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1092. To Buy or Not to Buy (20)相关的知识,希望对你有一定的参考价值。
简单题。
#include<cstdio> #include<cstring> const int maxn=1e5+10; char s1[maxn],s2[maxn]; int cnt[300]; int tot[300]; int main() { scanf("%s",s1); scanf("%s",s2); memset(cnt,0,sizeof cnt); memset(tot,0,sizeof tot); for(int i=0;s1[i];i++) cnt[s1[i]]++; for(int i=0;s2[i];i++) tot[s2[i]]++; bool flag=1; int ans=0; for(int i=0;i<300;i++) { if(cnt[i]<tot[i]){ flag=0; ans=ans+tot[i]-cnt[i]; } } if(flag==0) printf("No %d\n",ans); else printf("Yes %d\n",strlen(s1)-strlen(s2)); return 0; }
以上是关于PAT (Advanced Level) 1092. To Buy or Not to Buy (20)的主要内容,如果未能解决你的问题,请参考以下文章
PAT (Advanced Level) 1092. To Buy or Not to Buy (20)
PAT Advanced 1092 To Buy or Not to Buy (20分)
PAT Advanced 1092 To Buy or Not to Buy (20) [Hash散列]