func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mas[1010];   unordered_map<long long, int> sootv;   long long num[100100];   long long gcd(long long a, long long b) {     if (!a) return b;     return gcd(b % a, a);   }   int main() {     int n;     long long k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> mas[i];     }     if (k == 1) {       cout << 1 << endl;       int minidx = 1;       for (int i = 0; i < n; i++) {         if (mas[i] < mas[minidx]) minidx = i;       }       cout << minidx + 1;       return 0;     }     vector<long long> divs;     vector<long long> rdivs;     for (long long i = 1; i * i <= k; i++) {       if (k % i == 0) {         divs.push_back(i);         if (i * i != k) {           rdivs.push_back(k / i);         }       }     }     for (auto it = rdivs.rbegin(); it != rdivs.rend(); it++) {       divs.push_back(*it);     }     int cnt = 1;     sootv.rehash((int)(divs).size() * 5);     for (int i = 0; i < (int)(divs).size(); i++) {       sootv.emplace(divs[i], cnt);       num[cnt] = divs[i];       cnt++;     }     int oo = 1e9;     vector<vector<int> > dp(n + 3);     vector<vector<long long> > sum(n + 3);     vector<vector<int> > lst(n + 3);     for (int i = 0; i < (int)(dp).size(); i++) {       dp[i].resize(cnt + 3);       lst[i].resize(cnt + 3);       sum[i].resize(cnt + 3);       for (int j = 0; j < (int)(dp[i]).size(); j++) {         dp[i][j] = oo;       }       for (int j = 0; j < (int)(lst[i]).size(); j++) {         lst[i][j] = -1;       }       for (int j = 0; j < (int)(sum[i]).size(); j++) {         sum[i][j] = (long long)oo * (long long)oo;       }     }     dp[0][sootv[k]] = 0;     sum[0][sootv[k]] = 0;     int res = oo;     for (int i = 0; i < n; i++) {       for (int divi = 1; divi < cnt; divi++) {         if (dp[i][divi] >= oo) continue;         if (dp[i + 1][divi] > dp[i][divi] ||             dp[i + 1][divi] == dp[i][divi] && sum[i + 1][divi] > sum[i][divi]) {           lst[i + 1][divi] = divi;           dp[i + 1][divi] = dp[i][divi];           sum[i + 1][divi] = sum[i][divi];         }         long long nxt = num[divi] / gcd(num[divi], mas[i]);         if (nxt == num[divi]) continue;         int idx = sootv[nxt];         if (dp[i + 1][idx] > dp[i][divi] + 1 ||             dp[i + 1][idx] == dp[i][divi] + 1 &&                 sum[i + 1][idx] > sum[i][divi] + mas[i]) {           lst[i + 1][idx] = divi;           dp[i + 1][idx] = dp[i][divi] + 1;           sum[i + 1][idx] = sum[i][divi] + mas[i];         }       }     }     res = dp[n][sootv[1]];     if (res == oo) {       res = -1;       cout << res << endl;       return 0;     }     cout << res << endl;     vector<int> path;     int cur = sootv[1];     for (int i = n; i >= 1; i--) {       int l = lst[i][cur];       if (l != cur) {         path.push_back(i);       }       cur = l;       if ((int)(path).size() == res) break;     }     for (int i = (int)(path).size() - 1; i >= 0; i--) printf( %d  , path[i]);     return 0;   }   