【HDOJ】2386 Dart Challenge
纯粹母函数+滚动数组,水之。
- /* 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的更多相关文章
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
- 【HDOJ】【3516】Tree Construction
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...
- 【HDOJ】【3480】Division
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...
- 【HDOJ】【2829】Lawrence
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
- 【HDOJ】【3530】Subsequence
DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...
- 【HDOJ】【3068】最长回文
Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...
- 【HDOJ】【1512】Monkey King
数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...
随机推荐
- Modem常用概念
真实设备的标识,即DEVICE_ID.比如,Android设备是手机,这个DEVICE_ID可以同通过TelephonyManager.getDeviceId()获取,它根据不同的手机设备返回IMEI ...
- 4G上网卡NIDS拨号之Rmnet驱动
4G上网卡一般为双对外通讯口,一个是串口.一个是USB. 但是基于串口的常用波特率为115200,速度过于底下,所以大多使用USB. 1)一般来说常用ppp拨号方式,ppp拨号方式分为应用层pppd与 ...
- s标签可以if elseif else
首先引用s标签: <%@ taglib prefix="s" uri="/struts-tags" %> 使用s标签进行if elseif else ...
- Android 点击事件,4种回调。
1. 继承监听接口. 2. xml方式 : 设置 android:onClick 3. 内部类 4. 匿名类 ------------------------------------------- ...
- C# 之【获取网页响应码200】
做了个监控网站的C#项目,判断网站是否运行正常,采用的就是获取HTTP头返回的状态码. 比如状态码为200的就是网站正常,403是Forbidden,404是网页未找到这样. 代码如下: 首先是使用库 ...
- 设计模式之 State 状态模式
状态模式的核心在于 1. 状态的转换导致行为(Handle)的差异,比如人的状态是饿的时候,吃(Handle)的行为是2个馒头,人状态是不太饿的时候,吃(Handle)的行为是半个馒头 2. Stat ...
- C#后台程序与HTML页面中JS方法互调
此方法适用于 C#中嵌入WebBrowser(浏览器) 通过浏览器中加载的页面与C#的后台代码进行交互. 一.C#程序 1.在C#窗体中添加WebBrowser(浏览器),将页面的URL添加到浏览器中 ...
- javascript 自定义鼠标右键菜单
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 2016021903 - 下载安装使用Memory Analyzer
Memory Analyzer是做什么的? 分析java程序中分析内存泄露问题. 1.下载Memory Analyzer Memory Analyzer下载地址:http://www.eclipse. ...
- Spring MVC源码分析(续)——请求处理
转自:http://blog.csdn.net/shi1122/article/details/8041017 (转移位置了,时光隧道:http://www.jmatrix.org/spring/50 ...