func_code_string: #include <bits/stdc++.h>   using namespace std;   int SET(int n, int pos) { return n = n | (1 << pos); }   int RESET(int n, int pos) { return n = n & ~(1 << pos); }   int CHECK(int n, int pos) { return (bool)(n & (1 << pos)); }   int str2int(string s) {     stringstream ss(s);     int x;     ss >> x;     return x;   }   string int2str(int a) {     stringstream ss;     ss << a;     string str = ss.str();     return str;   }   string char2str(char a) {     stringstream ss;     ss << a;     string str = ss.str();     return str;   }   long long int bigMod(long long int n, long long int power, long long int MOD) {     if (power == 0) return 1;     if (power % 2 == 0) {       long long int ret = bigMod(n, power / 2, MOD);       return ((ret % MOD) * (ret % MOD)) % MOD;     } else       return ((n % MOD) * (bigMod(n, power - 1, MOD) % MOD)) % MOD;   }   long long int modInverse(long long int n, long long int MOD) {     return bigMod(n, MOD - 2, MOD);   }   int POW(int x, int y) {     int res = 1;     for (; y;) {       if ((y & 1)) {         res *= x;       }       x *= x;       y >>= 1;     }     return res;   }   int inverse(int x) {     double p = ((double)1.0) / x;     return (p) + 1e-9;   }   int gcd(int a, int b) {     while (b) b ^= a ^= b ^= a %= b;     return a;   }   int nC2(int n) { return n * (n - 1) / 2; }   long long int MOD(long long int n, long long int mod) {     if (n >= 0)       return n % mod;     else if (-n == mod)       return 0;     else       return mod + (n % mod);   }   int n, data[105], Mask[65], dp[105][(1 << 18) + 1], path[105][(1 << 18) + 1];   bool isPrime[65];   vector<int> prime;   void seive_N_logN(int N) {     memset(isPrime, true, sizeof isPrime);     prime.clear();     isPrime[1] = false;     for (int i = 4; i <= N; i = i + 2) isPrime[i] = false;     for (int i = 3; i * i <= N; i = i + 2) {       if (isPrime[i]) {         for (int j = i * i; j <= N; j += i) isPrime[j] = false;       }     }     for (int i = 1; i < N; i++)       if (isPrime[i]) prime.push_back(i);     for (int i = 1; i <= 60; i++) {       for (int j = 0; j < prime.size(); j++) {         if (i % prime[j] == 0) Mask[i] = SET(Mask[i], j);       }     }   }   int call(int i, int mask) {     if (i >= n) {       return 0;     }     int &ret = dp[i][mask];     if (ret != -1) return ret;     ret = 1000000000;     for (int j = 1; j <= 60; j++) {       if (mask & Mask[j]) continue;       int xx = call(i + 1, mask | Mask[j]) + abs(data[i] - j);       if (xx < ret) {         ret = xx;         path[i][mask] = j;       }     }     return ret;   }   int main() {     seive_N_logN(60);     int t, cas = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &data[i]);     }     memset(dp, -1, sizeof(dp));     call(0, 0);     int mask = 0;     for (int i = 0; i < n; i++) {       int ans = path[i][mask];       printf( %d  , ans);       mask |= Mask[ans];     }     printf(  n );     return 0;   }   