日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

BZOJ 3870: Our happy ending( 状压dp )

發(fā)布時間:2025/5/22 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BZOJ 3870: Our happy ending( 状压dp ) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

dp(i, s)表示考慮了前i個數(shù)后, 能取到的數(shù)的集合為s時的方案數(shù).對于1~min(L, K)枚舉更新, 剩下的直接乘就好了. 復雜度O(T*K*2^N)。。。好像有點大, 但是可以AC。。。。

------------------------------------------------------------------------------

#include<cstdio>

?

#include<cstring>#include<algorithm>using namespace std;typedef long long ll;#define b(i) (1 << (i))const int MOD = 1000000007;int N, g, L, dp[b(21)];inline void upd(int &x, int t) {if((x += t) >= MOD) x -= MOD;}int main() {int T;scanf("%d", &T);while(T--) {scanf("%d%d%d", &N, &g, &L);memset(dp, 0, sizeof dp);dp[1] = 1;int All = b(g + 1) - 1;while(N--) {for(int s = All; s; s--) if(dp[s]) {int t = dp[s];for(int i = min(g, L); i; i--)upd(dp[s | ((s << i) & All) | b(i)], t);if(L > g) upd(dp[s], ll(t) * (L - g) % MOD);}}int ans = 0;for(int i = All; i; i--)if(i & b(g)) upd(ans, dp[i]);printf("%d\n", ans);}return 0;}

------------------------------------------------------------------------------

3870: Our happy ending

Time Limit:?10 Sec??Memory Limit:?256 MB
Submit:?146??Solved:?84
[Submit][Status][Discuss]

Description

There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refuse any request from the devil. Also, this devil is looking like a very cute Loli.Y*wan still remember the day he first meets the devil. Now everything is done and the devil is gone. Y*wan feel very sad and suicide.You feel guilty after killing so many loli, so you suicide too.Nobody survive in this silly story, but there is still some hope, because this is just a silly background story during one programming contest!And the last problem is:Given a sequence a_1,a_2,...,a_n, if we can take some of them(each a_i can only be used once), and they sum to k, then we say this sequence is a good sequence.How many good sequence are there? Given that each a_i is an integer and 0<= a_i <= L.You should output the result modulo 10^9+7.

Input

The first line contains an integer T, denoting the number of the test cases.For each test case, the first line contains 3 integers n, k, L.T<=20, n,k<=20 , 0<=L<=10^9.

Output

For each cases, output the answer in a single line.

Sample Input

1
2 2 2

Sample Output

6

HINT

Source

By WJMZBMR

?

轉(zhuǎn)載于:https://www.cnblogs.com/JSZX11556/p/5175910.html

總結

以上是生活随笔為你收集整理的BZOJ 3870: Our happy ending( 状压dp )的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 裸体喂奶一级裸片 | 视频在线免费 | 国产69精品久久久 | 一区二区三区视频在线观看免费 | 国产乱偷| 天堂中文网在线 | 国产精品欧美性爱 | 亚洲综合影视 | 99久热在线精品996热是什么 | 熟妇人妻系列aⅴ无码专区友真希 | 日韩精品一区在线视频 | 国产孕妇孕交大片孕 | 久久久国产精品一区二区三区 | 男女免费视频网站 | 国产探花一区二区三区 | 久久精品观看 | 国产成人免费在线 | 亚洲一二三视频 | 欧美18一20男同69gay | 午夜aaa片一区二区专区 | 福利资源在线 | 西西午夜视频 | 成人tiktok黄短视频 | 国产69av| 青娱乐欧美 | 欧美巨鞭大战丰满少妇 | 日韩一级久久 | 一二三四国产精品 | 中文字幕天堂在线 | 亚洲精品www. | 爱上av| 不用播放器看av | 青娱乐精品视频 | 日韩色网站| 国产人妖在线播放 | 色图在线观看 | 久一区二区三区 | a天堂视频 | 亚洲av无码一区二区乱子仑 | 欧美日韩系列 | 亚洲 欧美 日韩系列 | 亚洲免费av片 | 奇米色777 | 国产精品一区二区三区四区五区 | 国产精品嫩草影院精东 | 99黄色| 亚洲精品一区二区三区影院忠贞 | av片免费看 | 日韩中文字幕 | 啪啪在线视频 | www.99av| 超碰在线99 | 蜜臀免费av | 狠狠干狠狠艹 | 欧美精品在线播放 | 国产欧美视频一区二区 | 日韩免费av一区二区 | 日韩欧美三级在线观看 | 一级毛片黄片 | 国产精品高潮视频 | 欧美人妖另类 | 国产粉嫩一区二区三区 | 夜夜躁狠狠躁日日躁 | 色综合天天综合网天天狠天天 | 天堂а√在线最新版中文在线 | 致命魔术电影高清在线观看 | 久久精品国产99精品国产亚洲性色 | 亚洲av综合色区无码一区 | 最新视频 - 8mav | 日本人妻不卡一区二区三区中文字幕 | 欧美精产国品一二三 | 性五月天 | aa一级黄色片| 国产超碰自拍 | 五月天伊人网 | 1000部国产精品成人观看 | 国产一区二区三区三州 | 肥熟女一区二区三肥熟女 | 神马午夜一区二区 | 国产精品无码av在线播放 | 久久久久久久久久久网站 | 国产色综合天天综合网 | 狠狠干伊人网 | 激情五月婷婷在线 | 欧美性理论片在线观看片免费 | 中文字幕一区二区三区人妻在线视频 | 亚洲精品九九 | 浮力影院草草 | 欧美xxxx×黑人性爽 | 亚洲国产精品suv | 超碰人人做| 国产精品一区二区无码免费看片 | 小泽玛利亚一区二区三区 | 麻豆黄色一级片 | 日韩午夜三级 | 狠狠操五月天 | 中文字幕免费在线观看 | 国产偷人妻精品一区二区在线 | 第一色网站|