fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. inline int power(int a, int b) {
  6. int x = 1;
  7. while (b) {
  8. if (b & 1) x *= a;
  9. a *= a;
  10. b >>= 1;
  11. }
  12. return x;
  13. }
  14.  
  15.  
  16. const int M = 1000000007;
  17. const int N = 3e5+9;
  18. const int INF = 2e9+1;
  19. const int LINF = 2000000000000000001;
  20.  
  21. //_ ***************************** START Below *******************************
  22.  
  23.  
  24.  
  25. void consistency(string s, string t) {
  26. vector<int> freq(26, 0), freq2(26, 0);
  27. for(int i=0; i<t.size(); i++){
  28. freq[t[i]-'a']++;
  29. }
  30.  
  31. for(int i=0; i<s.size(); i++){
  32. freq2[s[i]-'a']++;
  33. }
  34.  
  35. int mini = s.size();
  36. for(int i=0; i<26; i++){
  37. if(freq[i] == 0) continue;
  38. freq2[i] /= freq[i];
  39. mini = min(mini, freq2[i]);
  40. }
  41.  
  42. cout << mini << endl;
  43.  
  44. }
  45.  
  46. void solve() {
  47.  
  48. string s, t;
  49. cin >> s >> t;
  50. consistency(s, t) ;
  51.  
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58. int32_t main() {
  59. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  60.  
  61. int t = 1;
  62. while (t--) {
  63. solve();
  64. }
  65.  
  66. return 0;
  67. }
Success #stdin #stdout 0.01s 5296KB
stdin
dddeeeeeeeeeeepp deep
stdout
2