纯粹母函数+滚动数组,水之。

 /* 2386 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std; const int maxn = ; int cnt[];
int score[];
bool f[][maxn]; int main() {
int i, j, k;
int t, tt;
int n, m;
int ans, mx;
int cur, pre; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif scanf("%d", &tt);
for (t=; t<=tt; ++t) {
scanf("%d %d", &n, &m);
memset(cnt, , sizeof(cnt));
mx = ;
for (i=; i<n; ++i) {
scanf("%d", &k);
mx = max(k, mx);
++cnt[k];
++cnt[k<<];
++cnt[(k<<)+k];
}
--cnt[(mx<<)+mx];
for (n=i=; i<; ++i)
if (cnt[i])
score[n++] = i;
memset(f, false, sizeof(f));
f[][] = f[][] = true; for (j=, cur=, pre=; j<=m; ++j, pre=cur, cur=!cur) {
for (i=; i<=score[n-]*j; ++i) {
for (k=; k<n; ++k) {
if (f[pre][i] && i+score[k]<maxn)
f[cur][i+score[k]] = true;
}
}
}
ans = ;
for (i=; i<=score[n-]*m; ++i)
if (f[pre][i])
++ans;
printf("Scenario #%d:\n%d\n\n", t, ans);
} #ifndef ONLINE_JUDGE
printf("%d\n", (int)clock());
#endif return ;
}

【HDOJ】2386 Dart Challenge的更多相关文章

  1. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  2. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  3. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  4. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

  5. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  6. 【HDOJ】【3415】Max Sum of Max-K-sub-sequence

    DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...

  7. 【HDOJ】【3530】Subsequence

    DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...

  8. 【HDOJ】【3068】最长回文

    Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...

  9. 【HDOJ】【1512】Monkey King

    数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...

随机推荐

  1. Win8.1 与 pl2303驱动

    在8.1上最新的pl2303驱动都不支持Win8.1了.要使用老的驱动 http://www.drv5.cn/sfinfo/9385.html 这里这个驱动里面有五个文件,通过在设备管理器里面查看串口 ...

  2. JS如何封装一些列方法为一个对象的操作,然后集中管理这些操作,方便修改和调用

    var Api = { ajax:{ // 添加项目 旧! add_project : function(pro_name, html, css, js,callback) { $.post(&quo ...

  3. C# 的可空合并运算符(??)到底是怎样的宝宝?

    前言废语 也怪自己小白和不勤奋,没有系统的学习C#相关的东西,工作一年多还是初级小菜,深感不安,来到园子才发现好多钻研技术的人,也渐渐发现自己开始喜欢上了这个编程的世界.今日偶遇??操作符,发现我只看 ...

  4. C#/.net七牛云存储上传图片(文件)操作

    七牛云存储官方: C#SDK(http://developer.qiniu.com/docs/v6/sdk/csharp-sdk.html) 注册成为标准用户就可获得:10GB永久免费存储空间/ 每月 ...

  5. chrome跨域配置

    "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --use ...

  6. Stream To String , String To Stream

    public static string StreamToString(Stream stream) { stream.Position = 0; using (StreamReader stremR ...

  7. Oracle学习第三讲

    关联查询 笛卡尔积 指做关联操作的每个表的每一行都和其他表的每一行组合,假设两个表的记录条数分别为x和y,笛卡尔积将返回x*y条记录 例如:select count(*) from emp; sele ...

  8. OC基础-day03

    1#pragma mark - Day03_01_对象作为方法的返回值 1) 对象是可以作为方法的返回值的,返回值应该写这个类指针类型. - (MkDog *)buyDog; 代表方法执行完毕之后,有 ...

  9. css3学习--css3动画详解一(animation属性)

    ***介绍的属性并不完全,写的都是我认为容易混淆的难点属性,所以属性会在最后综合案例展示~ 一.Keyframes介绍: Keyframes被称为关键帧,其类似于Flash中的关键帧.在CSS3中其主 ...

  10. 添加标签2 jquery 和JS

    TAG添加标签 做了个方法方便调用 一.JS版本 <!DOCTYPE html> <html lang="en"> <head> <met ...