HDU 6092 Rikka with Subset(dp)
http://acm.hdu.edu.cn/showproblem.php?pid=6092
题意:
给出两个数组A和B,A数组一共可以有(1<<n)种不同的集合组合,B中则记录了每个数出现的次数,现在要根据B数组来推出A数组最小的序列。
思路:
如果$B_{i}$是 B 数组中除了$B_{0}$ 以外第一个值不为 0 的位置,那么显然 i 就是 A 中的最小数。
那么我们每次取出$B_{i}$一个数,对于后面的数组来说,满足$B_{j}=B_{j}-B_{j-i}$,为什么?
其实仔细想想就可以了,比如现在取出的i为2,那么$B_{5}$的方案数是不是可以通过$B_{3}$加上2来合成,所以这也就是上面的式子了。
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,ll> pll;
const int INF = 0x3f3f3f3f;
const int maxn=1e4+; int n, m;
ll a[];
ll b[maxn]; int main()
{
//freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
int cnt=;
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++) scanf("%I64d",&b[i]);
for(int i=;i<=m;i++)
{
if(b[i])
{
a[++cnt]=i;
for(int j=i;j<=m;j++)
{
b[j]-=b[j-i];
}
i--;
}
}
for(int i=;i<=cnt;i++)
{
printf("%d",a[i]);
if(i!=cnt) printf(" ");
else printf("\n");
}
}
return ;
}
HDU 6092 Rikka with Subset(dp)的更多相关文章
- hdu 6092 Rikka with Subset(逆向01背包+思维)
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2017 ACM暑期多校联合训练 - Team 5 1008 HDU 6092 Rikka with Subset (找规律)
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...
- hdu 6092 Rikka with Subset(多重背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6092 #include <cstdio> #include <iostream> ...
- HDU 5829 Rikka with Subset(NTT)
题意 给定 \(n\) 个数 \(a_1,a_2,\cdots a_n\),对于每个 \(K\in[1,n]\) ,求出 \(n\) 个数的每个子集的前 \(K\) 大数的和,输出每个值,对 \(99 ...
- HDU 6092 17多校5 Rikka with Subset(dp+思维)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- HDU 6092 Rikka with Subset
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU 1864 最大报销额(DP)
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1864 题目: 最大报销额 Time Limit: 1000/1000 MS (Java/Others) ...
- HDU 6092`Rikka with Subset 01背包变形
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU 2639 Bone Collector II (dp)
题目链接 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took part in ...
随机推荐
- 对innodb_flush_log_at_commit参数的写日志和刷盘行为进行图解
对innodb_flush_log_at_commit参数的写日志和刷盘行为进行图解
- Choose the best route(迪杰斯特拉)
通过做这题,发现了自己的问题很大,做题不是贴代码,而是要了解思想:这题考的是有一个起点的集合,求起点集合到一个终点的最短距离, 本来想用Floy的但一看map[1000][1000]超时,有向图,逆序 ...
- Look for the Air Jordan 32 in full family sizing
Following the release of the 'Rosso Corsa' colorway, Jordan Brand is now set to officially launch th ...
- myeclipse自带的数据库查看文件
jdbc:mysql://localhost:3306/videocms?useUnicode=true&characterEncoding=utf8
- kendo grid应用经验总结
学习网址 https://docs.telerik.com/kendo-ui/controls/editors/dropdownlist/overview https://demos.telerik. ...
- C++飞机大战
#include<windows.h> #include"resource.h" #include<stdlib.h> #include<time.h ...
- 【kafka学习之三】kafka集群运维
kafka集群维护一.kafka集群启停#启动kafka/home/cluster/kafka211/bin/kafka-server-start.sh -daemon /home/cluster/k ...
- 中国程序化购买广告解析:RTB/DSP/Ad Exchange/SSP/DMP,思维导图
中国程序化购买广告解析:RTB/DSP/Ad Exchange/SSP/DMP 概念 程序化购买( Programmatic Buying):通过数字化.自动化.系统化的方式改造广告主.代理公司.媒体 ...
- NSDictionary打印编码改中文的方法
1,转NSData NSData *jsonData = [NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrett ...
- Shell学习笔记之shell脚本和python脚本实现批量ping IP测试
0x00 将IP列表放到txt文件内 先建一个存放ip列表的txt文件: [root@yysslopenvpn01 ~]# cat hostip.txt 192.168.130.1 192.168.1 ...