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 ...
随机推荐
- OC 手势可能出现的问题
oc手势有分別是 Tap(点一下).Pinch(二指往內或往外拨动).Rotation(旋转).Swipe(滑动,快速移动).Pan (拖移,慢速移动)以及 LongPress(长按). UITapG ...
- [MySQL 5.6] MySQL 5.6 group commit 性能测试及内部实现流程
[MySQL 5.6] MySQL 5.6 group commit 性能测试及内部实现流程 http://mysqllover.com/?p=581 尽管Mariadb以及Facebook在long ...
- spring boot读取配置文件
一.springboot配置文件 核心配置文件和自定义配置文件.核心配置文件是指在resources根目录下的application.properties或application.yml配置文 ...
- [py]django上线部署-uwsgi+nginx+py3/django1.10
https://github.com/lannyMa/django-uwsgi-nginx.git 单机调试启动-确保项目代码没问题 - 克隆代码进入项目 git clone https://gith ...
- [py][mx]django分页第三方模块django-pure-pagination
前台的这些数据都是从后台取来的 分页模块django-pure-pagination - 一款基于django pagination封装的更好用的分页模块 https://github.com/jam ...
- python基础24 -----python中的各种锁
一.全局解释器锁(GIL) 1.什么是全局解释器锁 在同一个进程中只要有一个线程获取了全局解释器(cpu)的使用权限,那么其他的线程就必须等待该线程的全局解释器(cpu)使 用权消失后才能使用全局解释 ...
- linux中的各种$号 位置参数变量
位置参数变量 $n #/bin/bash echo $0(代表命令本身); echo $1; (代表第几个参数) echo $2; [root@LocalWeb01 ~]# ./1.sh ...
- JVisualVM远程监控
本文主要转自:http://blog.iamzsx.me/show.html?id=394002 http://www.wl566.com/wz/64022.html 1. 通过JMX方式监控远程li ...
- Linux基础命令---sum,cksum
cksum 检查文件的crc是否正确,统计文件的字节数. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法 cks ...
- 处理内容有&特殊字符thinkphp返回xml无法解析的问题<![CDATA[xxx]]>
处理内容有&特殊字符thinkphp返回xml无法解析的问题<![CDATA[xxx]]> // xml 转义特殊字符 如&'" <![CDATA[&quo ...