2016暑假多校联合---To My Girlfriend
I never forget the moment I met with you.You carefully asked me: "I have a very difficult problem. Can you teach me?".I replied with a smile, "of course"."I have n items, their weight was a[i]",you said,"Let's define f(i,j,k,l,m) to be the number of the subset of the weight of n items was m in total and has No.i and No.j items without No.k and No.l items.""And then," I asked.You said:"I want to know
Sincerely yours,
Liao
Each case contains 2 integers n, s (4≤n≤1000,1≤s≤1000). The next line contains n numbers: a1,a2,…,an (1≤ai≤1000).
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = ;
const int mod = 1e9+;
int a[maxn];
int dp[maxn][maxn][][];
int n,s; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(dp,,sizeof(dp));
scanf("%d%d",&n,&s);
for(int i = ;i<=n;i++)
scanf("%d",&a[i]);
dp[][][][]=;
for(int i = ;i<=n;i++)
for(int j = ;j<=s;j++)
for(int s1 = ;s1<=;s1++)
for(int s2 = ;s2<=;s2++)
{
dp[i][j][s1][s2]=(dp[i][j][s1][s2]+dp[i-][j][s1][s2])%mod;
if(j>=a[i])
dp[i][j][s1][s2]=(dp[i][j][s1][s2]+dp[i-][j-a[i]][s1][s2])%mod;
if(s1>&&j>=a[i])
dp[i][j][s1][s2]=(dp[i][j][s1][s2]+dp[i-][j-a[i]][s1-][s2])%mod;
if(s2>)
dp[i][j][s1][s2]=(dp[i][j][s1][s2]+dp[i-][j][s1][s2-])%mod;
}
LL ans = ;
for(int i = ;i<=s;i++)
ans = (ans+dp[n][i][][])%mod;
printf("%lld\n",ans*%mod);
}
}
2016暑假多校联合---To My Girlfriend的更多相关文章
- 2016暑假多校联合---Rikka with Sequence (线段树)
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...
- 2016暑假多校联合---Windows 10
2016暑假多校联合---Windows 10(HDU:5802) Problem Description Long long ago, there was an old monk living on ...
- 2016暑假多校联合---Substring(后缀数组)
2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...
- 2016暑假多校联合---A Simple Chess
2016暑假多校联合---A Simple Chess Problem Description There is a n×m board, a chess want to go to the po ...
- 2016暑假多校联合---Another Meaning
2016暑假多校联合---Another Meaning Problem Description As is known to all, in many cases, a word has two m ...
- 2016暑假多校联合---Death Sequence(递推、前向星)
原题链接 Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historia ...
- 2016暑假多校联合---Counting Intersections
原题链接 Problem Description Given some segments which are paralleled to the coordinate axis. You need t ...
- 2016暑假多校联合---Joint Stacks (STL)
HDU 5818 Problem Description A stack is a data structure in which all insertions and deletions of e ...
- 2016暑假多校联合---GCD
Problem Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). ...
随机推荐
- 1编写一个Java程序,计算半径为3.0的圆周长和面积并输出结果。2编写一个Java项目,定义包,在包下定义包含main方法的类。
- iOS-数据持久化-属性列表
属性列表 属性列表文件是一种XML文件,Foundation框架中的数组和字典等都可以于属性列表文件相互转换. NSArray类常用读写属性列表文件的方法: +arrayWithContentsOfF ...
- 安装Jenkins
jenkins是一个广泛用于持续构建的可视化web工具,持续构建说得更直白点,就是各种项目的"自动化"编译.打包.分发部署的工具 1.jenkins的官网 2.jenkins各个系 ...
- 使用supervisor提高nodejs调试效率
如果你有PHP 开发经验,会习惯在修改PHP 脚本后直接刷新浏览器以观察结果,而你 在开发Node.js 实现的HTTP 应用时会发现,无论你修改了代码的哪一部份,都必须终止 Node.js 再重新运 ...
- Topology and Geometry in OpenCascade-Edge
Topology and Geometry in OpenCascade-Edge eryar@163.com 摘要Abstract:本文简要介绍了几何造型中的边界表示法(BRep),并结合程序说明O ...
- Android UI设计中一些不错的示例及第三方控件
1.二级ListView自定义布局ExpandableListView http://pan.baidu.com/s/1mhlJh12 密码:nhc2 2.ListView实现各种动画效果ListVi ...
- 使用 jQuery & CSS3 实现翻转的作品集滑块
作为 Web 开发人员,我想你一定见过各种各样的图片滑块效果.展示产品或者个人作品的方法有很多,其中之一是使用网格样式的滑块效果.在本教程中,我将分享如何使用 jQuery 和 CSS3 变换实现翻转 ...
- 如何调试PHP程序
一.PHP自带的调试功能 1.修改php.ini )开发环境 需要打开报错输出显示,方便开发者调试. display_errors = On )生产环境 不能直接将错误输出,而是记入日志,以免透露路径 ...
- pe创建激活administrator后消除问题,删除用户问题
启动pe进入电脑,打开清楚密码,然后选择administrator,点击激活.然后就可以用administrator登陆电脑. 使用完毕后,想要注销administrator. 方法1. 在cmd中输 ...
- 使用Spark分析拉勾网招聘信息(三): BMR 入门
简述 本文,意在以最小的篇幅,来帮助对大数据和Spark感兴趣的小伙伴,能尽快搭建一个可用的Spark开发环境.力求言简意赅.文章,不敢自称BMR的最佳实践,但绝对可以帮助初学者,迅速入门,能够专心于 ...