const int MAXN = 21; int dp[1 << MAXN]; int main() { int T, n, sum, Max; RI(T); FE(kase, 1, T) { RIII(n, sum, Max); int Min = min(sum, Max); int all = 1 << (sum + 1); CLR(dp, 0); dp[1] = 1; REP(i, n) { FED(j, all - 1, 1) { if (dp[j] == 0) continue; int x = dp[j]; for (int k = 1; k <= Min; k++) { int nxt = j | ((j << k) & (all - 1)); dp[nxt] += x; if (dp[nxt] >= MOD) dp[nxt] -= MOD; } if (Max - Min > 0) dp[j] = (dp[j] + 1LL * (Max - Min) * x) % MOD; } } int ans = 0; FF(i, 1 << sum, all) { ans += dp[i]; if (ans >= MOD) ans -= MOD; } WI(ans); } return 0; }
Our happy ending,布布扣,bubuko.com
原文地址:http://blog.csdn.net/wty__/article/details/38373441