func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 3;   int N, Q, K;   long long a[MAXN], sum[MAXN], save[MAXN];   int main() {     scanf( %d , &N);     memset((save), (-1), sizeof(save));     for (int i = 1; i <= N; ++i) scanf( %lld , &a[i]);     sort(a + 1, a + 1 + N);     for (int i = 1; i <= N; ++i) sum[i] = sum[i - 1] + a[i];     scanf( %d , &Q);     while (Q--) {       scanf( %d , &K);       if (save[K] != -1) {         printf( %lld n , save[K]);         continue;       }       long long ans = 0, deep = 1, deep_size = K, now = N - 1;       while (now > 0) {         long long next = max(0ll, now - deep_size);         ans += (sum[now] - sum[next]) * deep;         ++deep;         now -= deep_size;         deep_size *= K;       }       save[K] = ans;       printf( %lld , ans);       putchar(Q ?     :   n );     }     return 0;   }   