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)的更多相关文章

  1. hdu 6092 Rikka with Subset(逆向01背包+思维)

    Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. 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 ...

  3. hdu 6092 Rikka with Subset(多重背包)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6092 #include <cstdio> #include <iostream> ...

  4. HDU 5829 Rikka with Subset(NTT)

    题意 给定 \(n\) 个数 \(a_1,a_2,\cdots a_n\),对于每个 \(K\in[1,n]\) ,求出 \(n\) 个数的每个子集的前 \(K\) 大数的和,输出每个值,对 \(99 ...

  5. 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 ...

  6. HDU 6092 Rikka with Subset

    Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  7. HDU 1864 最大报销额(DP)

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1864 题目: 最大报销额 Time Limit: 1000/1000 MS (Java/Others) ...

  8. HDU 6092`Rikka with Subset 01背包变形

    Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  9. 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 ...

随机推荐

  1. 003-redis-命令-key操作,字符串操作

    Redis 键(key) Redis 键命令用于管理 redis 的键. 序号 命令及描述 1 DEL key该命令用于在 key 存在时删除 key. 2 DUMP key 序列化给定 key ,并 ...

  2. HTTP API响应数据规范整理

    概述 本文档为本人对长期开发API接口所整理的经验总结,如有不完善或不合理的地方,望各位多提意见. 文档目的为规范服务器端API接口,便于服务器端与客户端代码重用.服务器端和客户端可根据实际所定义规范 ...

  3. 发现《深入理解C++11》中扩展的friend代码的错误

    目前在总结现代C++的新特性,看了<深入理解C++11>这本书. 今天看到扩展的friend语法这一节,遇到了问题.本节电子版内容参见:https://book.2cto.com/2013 ...

  4. mysql数据库的初始化及相关配置

    接着上篇文章我们继续探讨在安装完mysq数据库之后的一些相关配置: 一.mysql数据库的初始化 我们在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是咱们的数据库服务,我们通 ...

  5. ajax请求session失效重定向到登录页面

    在ajax请求的页面引入一个自定义的AjaxRedirect.js的文件 AjaxRedirect.js的代码如下: $(function(){ $.ajaxSetup({ type: 'POST', ...

  6. iOS UI基础-3.0图片浏览器及plist使用

    需求: 1.显示当前图片序号/总图片数 2.显示图片 3.上一张图片.下一张图片转换 4.显示图片描述 下面用代码来实现 // // UYViewController.m // 3.0图片查看器 // ...

  7. Twitter OA prepare: Anagram is A Palindrome

    Algorithm: Count the number of occurrence of each character. Only one character with odd occurrence ...

  8. linux系统安装 dig和nslookup命令

    Fedora / Centos:1.yum install bind-utils Ubuntu: 1.sudo apt-get install dnsutils Debian: 1.2 apt-get ...

  9. PhoneGap+Cordova+SenchaTouch-01-环境搭建

    转http://my.oschina.net/zhongwenhao/blog/369465 环境搭建基于 windows  ,mac系统可以借鉴 1.安装NodeJS 和ruby http://no ...

  10. 187. Repeated DNA Sequences(建立词典,遍历一遍 o(n))

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...