#include <cstdio> int main() { int N, Q, S = 1; while (scanf("%d%d", &N, &Q) && N) { printf("SET %d:\n", S++); int num[200]; for (int i = 0; i < N; i++) { scanf("%d", &num[i]); } int q = 1; while (Q--) { int D, M; scanf("%d%d", &D, &M); long long dp[11][20] = {1}; for (int i = 0; i < N; i++) { for (int m = M; m; m--) { for (int r = 0; r < D; r++) { dp[m][r] += dp[m - 1][(r - num[i] % D + D) % D]; } } } printf("QUERY %d: %lld\n", q++, dp[M][0]); } } return 0; }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2013年9月1日
UVa 10616 - Divisible Group Sums
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言