#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } unsigned M; void Add(unsigned &t, unsigned f) { t += f; t = (t >= M) ? (t - M) : t; } int N, K; int A[110]; int ASum[110]; int lbs[110], ubs[110]; unsigned buf[3'800'000]; unsigned *dp[110]; unsigned ans[100'010]; int main() { for (; ~scanf("%d%u%d", &N, &M, &K); ) { for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); } sort(A, A + N); const bool rev = chmin(K, N - K); for (int i = 0; i < N; ++i) { ASum[i + 1] = ASum[i] + A[i]; } for (int k = 0; k <= K; ++k) { lbs[k] = ASum[k]; ubs[k] = ASum[N] - ASum[N - k]; } { unsigned *ptr = buf; for (int k = 0; k <= K; ++k) { dp[k] = ptr - lbs[k]; ptr += (ubs[k] - lbs[k] + 1); } } #ifdef LOCAL memset(buf, 0, sizeof(buf)); memset(ans, 0, sizeof(ans)); #endif dp[0][0] = 1 % M; for (int i = 0; i < N; ++i) { for (int k = K; --k >= 0; ) { for (int x = lbs[k]; x <= ubs[k]; ++x) { Add(dp[k + 1][x + A[i]], dp[k][x]); } } } for (int x = lbs[K]; x <= ubs[K]; ++x) { ans[x] = dp[K][x]; } if (rev) { reverse(ans, ans + (ASum[N] + 1)); } for (int x = 1; x <= ASum[N]; ++x) { if (x > 1) printf(" "); printf("%u", ans[x]); } puts(""); } return 0; }