fork download
  1. #include <bits/stdc++.h>
  2. using ll=long long int;
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. string s,t;
  9. cin>>s>>t;
  10. unordered_map<char,int>mp1,mp2;
  11. for(int i=0;i<s.size();i++){
  12. mp1[s[i]]++;
  13. }
  14. for(int i=0;i<t.size();i++){
  15. mp2[t[i]]++;
  16. }
  17. int cnt=100000;
  18. int val=100000;
  19. for(int i=0;i<t.size();i++){
  20. if(mp1.find(t[i])==mp1.end()){
  21. return 0;
  22. }
  23. val=mp1[t[i]]/mp2[t[i]];
  24.  
  25. cnt=min(cnt,val);
  26.  
  27. }
  28. cout<<cnt<<endl;
  29. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
100000