#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; int N, K; int A[95]; unsigned dp[45][100'010]; void Add(unsigned &t, unsigned f) { t += f; t = (t >= M) ? (t - M) : t; } 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); int sumA = 0; for (int i = 0; i < N; ++i) { sumA += A[i]; } const bool rev = chmin(K, N - K); #ifdef LOCAL memset(dp, 0, sizeof(dp)); #endif dp[0][0] = 1 % M; for (int i = 0; i < N; ++i) { for (int k = K; --k >= 0; ) { for (int x = 0; x + A[i] <= sumA; ++x) { Add(dp[k + 1][x + A[i]], dp[k][x]); } } } if (rev) { reverse(dp[K], dp[K] + (sumA + 1)); } for (int x = 1; x <= sumA; ++x) { if (x > 1) printf(" "); printf("%d", dp[K][x]); } puts(""); } return 0; }