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

  1. /* 2386 */
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5. #include <queue>
  6. #include <set>
  7. #include <stack>
  8. #include <vector>
  9. #include <algorithm>
  10. #include <cstdio>
  11. #include <cmath>
  12. #include <ctime>
  13. #include <cstring>
  14. #include <climits>
  15. #include <cctype>
  16. using namespace std;
  17.  
  18. const int maxn = ;
  19.  
  20. int cnt[];
  21. int score[];
  22. bool f[][maxn];
  23.  
  24. int main() {
  25. int i, j, k;
  26. int t, tt;
  27. int n, m;
  28. int ans, mx;
  29. int cur, pre;
  30.  
  31. #ifndef ONLINE_JUDGE
  32. freopen("data.in", "r", stdin);
  33. freopen("data.out", "w", stdout);
  34. #endif
  35.  
  36. scanf("%d", &tt);
  37. for (t=; t<=tt; ++t) {
  38. scanf("%d %d", &n, &m);
  39. memset(cnt, , sizeof(cnt));
  40. mx = ;
  41. for (i=; i<n; ++i) {
  42. scanf("%d", &k);
  43. mx = max(k, mx);
  44. ++cnt[k];
  45. ++cnt[k<<];
  46. ++cnt[(k<<)+k];
  47. }
  48. --cnt[(mx<<)+mx];
  49. for (n=i=; i<; ++i)
  50. if (cnt[i])
  51. score[n++] = i;
  52. memset(f, false, sizeof(f));
  53. f[][] = f[][] = true;
  54.  
  55. for (j=, cur=, pre=; j<=m; ++j, pre=cur, cur=!cur) {
  56. for (i=; i<=score[n-]*j; ++i) {
  57. for (k=; k<n; ++k) {
  58. if (f[pre][i] && i+score[k]<maxn)
  59. f[cur][i+score[k]] = true;
  60. }
  61. }
  62. }
  63. ans = ;
  64. for (i=; i<=score[n-]*m; ++i)
  65. if (f[pre][i])
  66. ++ans;
  67. printf("Scenario #%d:\n%d\n\n", t, ans);
  68. }
  69.  
  70. #ifndef ONLINE_JUDGE
  71. printf("%d\n", (int)clock());
  72. #endif
  73.  
  74. return ;
  75. }

【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. Modem常用概念

    真实设备的标识,即DEVICE_ID.比如,Android设备是手机,这个DEVICE_ID可以同通过TelephonyManager.getDeviceId()获取,它根据不同的手机设备返回IMEI ...

  2. 4G上网卡NIDS拨号之Rmnet驱动

    4G上网卡一般为双对外通讯口,一个是串口.一个是USB. 但是基于串口的常用波特率为115200,速度过于底下,所以大多使用USB. 1)一般来说常用ppp拨号方式,ppp拨号方式分为应用层pppd与 ...

  3. s标签可以if elseif else

    首先引用s标签: <%@ taglib prefix="s" uri="/struts-tags" %> 使用s标签进行if elseif else ...

  4. Android 点击事件,4种回调。

    1.  继承监听接口. 2.  xml方式 : 设置 android:onClick 3. 内部类 4. 匿名类 ------------------------------------------- ...

  5. C# 之【获取网页响应码200】

    做了个监控网站的C#项目,判断网站是否运行正常,采用的就是获取HTTP头返回的状态码. 比如状态码为200的就是网站正常,403是Forbidden,404是网页未找到这样. 代码如下: 首先是使用库 ...

  6. 设计模式之 State 状态模式

    状态模式的核心在于 1. 状态的转换导致行为(Handle)的差异,比如人的状态是饿的时候,吃(Handle)的行为是2个馒头,人状态是不太饿的时候,吃(Handle)的行为是半个馒头 2. Stat ...

  7. C#后台程序与HTML页面中JS方法互调

    此方法适用于 C#中嵌入WebBrowser(浏览器) 通过浏览器中加载的页面与C#的后台代码进行交互. 一.C#程序 1.在C#窗体中添加WebBrowser(浏览器),将页面的URL添加到浏览器中 ...

  8. javascript 自定义鼠标右键菜单

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  9. 2016021903 - 下载安装使用Memory Analyzer

    Memory Analyzer是做什么的? 分析java程序中分析内存泄露问题. 1.下载Memory Analyzer Memory Analyzer下载地址:http://www.eclipse. ...

  10. Spring MVC源码分析(续)——请求处理

    转自:http://blog.csdn.net/shi1122/article/details/8041017 (转移位置了,时光隧道:http://www.jmatrix.org/spring/50 ...