func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxx = 500 + 7;   const int maxn = 100 + 7;   const long long mod = 1E9 + 7;   const int maxs = 2 * (1E7) + 5;   const int maxm = 100 + 3;   const long long maxk = 1e13;   long double dp[maxn][maxn];   int last[1000];   char seq[maxn];   long long n, k;   void init() {     cin >> n >> k;     cin >> seq;     memset(last, -1, sizeof(last));   }   void solve() {     dp[0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= i; j++) {         if (!j) {           dp[i][j] = 1;           continue;         }         dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];         if (last[seq[i - 1]] != -1) dp[i][j] -= dp[last[seq[i - 1]]][j - 1];       }       last[seq[i - 1]] = i - 1;     }     long long cost = 0;     long double kk = k;     for (long long i = n; i >= 0; i--) {       long double tt = min(kk, dp[n][i]);       cost += tt * (n - i);       kk -= min(tt, kk);     }     if (kk > 0)       cout << -1 << endl;     else       cout << (long long)cost << endl;   }   int main(void) {     init();     solve();     return 0;   }   