func_code_string: #include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const long long MOD = 1000000000 + 7;   const int MAXN = 100000 + 5;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   inline long long readLL() {     char ch;     bool flag = false;     long long a = 0;     while (!((((ch = getchar()) >=  0 ) && (ch <=  9 )) || (ch ==  - )))       ;     if (ch !=  - ) {       a *= 10;       a += ch -  0 ;     } else {       flag = true;     }     while (((ch = getchar()) >=  0 ) && (ch <=  9 )) {       a *= 10;       a += ch -  0 ;     }     if (flag) a = -a;     return a;   }   inline int read() {     char ch;     bool flag = false;     int a = 0;     while (!((((ch = getchar()) >=  0 ) && (ch <=  9 )) || (ch ==  - )))       ;     if (ch !=  - ) {       a *= 10;       a += ch -  0 ;     } else {       flag = true;     }     while (((ch = getchar()) >=  0 ) && (ch <=  9 )) {       a *= 10;       a += ch -  0 ;     }     if (flag) a = -a;     return a;   }   const int N = 1000000;   long long prime[N];   bool check[N];   int totp;   void Eular() {     memset(check, false, sizeof(check));     totp = 0;     for (int i = 2; i < N; i++) {       if (!check[i]) prime[totp++] = i;       for (int j = 0; j < totp; j++) {         if (i * prime[j] >= N) break;         check[i * prime[j]] = true;         if (i % prime[j] == 0) break;       }     }   }   int totfj;   long long fj[20];   int numfj[20];   void fenjie(long long n) {     totfj = 0;     for (int i = 0, __END__ = (int)(totp); i < __END__; i++) {       if (n < prime[i]) break;       if (n % prime[i] == 0) {         numfj[totfj] = 0;         fj[totfj] = prime[i];         while (n % prime[i] == 0) n /= prime[i], numfj[totfj]++;         totfj++;       }     }     if (n > 1) {       fj[totfj++] = n;     }   }   int totys;   long long ys[10010];   void getys(long long n) {     fenjie(n);     totys = 0;     ys[totys++] = 1;     int tmp;     long long mul;     for (int i = 0, __END__ = (int)(totfj); i < __END__; i++) {       tmp = totys;       mul = 1;       for (int j = 0, __END__ = (int)(numfj[i]); j < __END__; j++) {         mul *= fj[i];         for (int k = 0, __END__ = (int)(tmp); k < __END__; k++)           ys[totys++] = mul * ys[k];       }     }   }   long long a[1010];   long long b[1010];   int dp[1010][10010];   pair<pair<int, int>, long long> path[1010][10010];   unordered_map<long long, int> zip;   unordered_map<int, long long> unzip;   const int inf = 100000;   const long long infLL = 9000000000000000000LL;   int main() {     Eular();     int n;     n = read();     long long k;     k = readLL();     for (int i = 1, __END__ = (int)(n); i <= __END__; i++) a[i] = readLL();     for (int i = 1, __END__ = (int)(n); i <= __END__; i++) b[i] = gcd(k, a[i]);     if (k == 1) {       int ans = 1;       for (int i = 1, __END__ = (int)(n); i <= __END__; i++)         if (a[ans] > a[i]) ans = i;       cout <<  1  << endl;       cout << ans << endl;       return 0;     }     getys(k);     if (totys >= 10010) return -1;     for (int i = 0, __END__ = (int)(totys); i < __END__; i++)       zip[ys[i]] = i, unzip[i] = ys[i];     for (int i = 0, __END__ = (int)(n + 1); i < __END__; i++)       for (int j = 0, __END__ = (int)(totys); j < __END__; j++) dp[i][j] = inf;     path[n][totys - 1] = make_pair(make_pair(inf, inf), infLL);     path[0][0] = make_pair(make_pair(inf, inf), 0LL);     long long now;     long long nxt;     int inow;     int inxt;     dp[0][0] = 0;     for (int i = 0, __END__ = (int)(n); i < __END__; i++) {       for (int j = 0, __END__ = (int)(totys); j < __END__; j++)         if (dp[i][j] != inf)           if (dp[i + 1][j] == dp[i][j]) {             if (path[i + 1][j].second > path[i][j].second)               path[i + 1][j] = path[i][j];           }       for (int j = 0, __END__ = (int)(totys); j < __END__; j++)         if (dp[i + 1][j] > dp[i][j]) {           dp[i + 1][j] = dp[i][j];           path[i + 1][j] = path[i][j];         }       for (int j = 0, __END__ = (int)(totys); j < __END__; j++)         if (dp[i][j] != inf) {           now = unzip[j];           nxt = gcd(k / b[i + 1], now) * b[i + 1];           inxt = zip[nxt];           if (dp[i + 1][inxt] == dp[i][j] + 1) {             if (path[i + 1][inxt].second > path[i][j].second + a[i + 1])               path[i + 1][inxt] =                   make_pair(make_pair(i, j), path[i][j].second + a[i + 1]);           }           if (dp[i + 1][inxt] > dp[i][j] + 1) {             dp[i + 1][inxt] = dp[i][j] + 1;             path[i + 1][inxt] =                 make_pair(make_pair(i, j), path[i][j].second + a[i + 1]);           }         }     }     if (dp[n][totys - 1] == inf) {       puts( -1 );       return 0;     }     printf( %d n , dp[n][totys - 1]);     pair<int, int> pit(n, totys - 1);     int flag = 1;     while (pit.first != inf && pit.second != inf) {       pit = path[pit.first][pit.second].first;       if (pit.first == inf) break;       if (flag)         flag = 0;       else         printf(   );       printf( %d , pit.first + 1);     }     puts(  );     return 0;   }   