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). ...
随机推荐
- 知方可补不足~用CDC功能来对数据库变更进行捕捉
回到目录 如果我们希望监视一个数据表的变化,在sql2008之前的版本里,在数据库端可能想到的只有触发器,或者在程序端通过监视自己的insert,update,delete来实现相应的功能,这种实现无 ...
- Atitit 面向对象 封装的实现原理
Atitit 面向对象 封装的实现原理 1.1. 动态对象的模拟使用map+函数接口可以实现1 1.2. 在用结构体 + 函数指针 模拟 对象 1 1.3. This指针..1 1.4. " ...
- Atitit dsl实现(1)------异常的库模式实现 异常的ast结构
Atitit dsl实现(1)------异常的库模式实现 异常的ast结构 1.1. Keyword 1 1.2. 异常的ast模型 1 1.3. Astview的jar org.eclipse. ...
- iOS $299刀企业证书申请的过程以及细节补充(二)
上篇博客写的过程中,没有图,也没有相应的说明.这次再补充一些信息: 1.从 https://developer.apple.com/ios/enroll/dunsLookupForm.action 申 ...
- C# 集合类 :(Array、 Arraylist、List、Hashtable、Dictionary、Stack、Queue)
我们用的比较多的非泛型集合类主要有 ArrayList类 和 HashTable类.我们经常用HashTable 来存储将要写入到数据库或者返回的信息,在这之间要不断的进行类型的转化,增加了系统装箱和 ...
- mysqldump导出不包含存储过程
mysqldump导出不包含存储过程 mysqldump -u 数据库用户名 -p -n -t -d -R --triggers=false 数据库名 > 文件名 这样单独把存储过程和函数导出 ...
- 深入理解CSS中的空白符和换行
前面的话 CSS3新增了两个换行属性word-wrap和word-break.把空白符和换行放在一起说,是因为实际上空白符是包括换行的,且常用的文本不换行是使用的空白符的属性white-space: ...
- java简单词法分析器(源码下载)
java简单词法分析器 : http://files.cnblogs.com/files/hujunzheng/%E7%AE%80%E5%8D%95%E8%AF%8D%E6%B3%95%E5%88%8 ...
- java中Object.equals()简单用法
/* equals()方法默认的比较两个对象的引用! */ class Child { int num; public Child(int x){ num = x; } //人文的抛出运行时异常的好处 ...
- Spring MVC 学习总结(三)——请求处理方法Action详解
Spring MVC中每个控制器中可以定义多个请求处理方法,我们把这种请求处理方法简称为Action,每个请求处理方法可以有多个不同的参数,以及一个多种类型的返回结果. 一.Action参数类型 如果 ...