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. 001-Spring Cloud Edgware.SR3 升级最新 Finchley.SR1,spring boot 1.5.9.RELEASE 升级2.0.4.RELEASE注意问题点

    一.前提 升级前 => 升级后 Spring Boot 1.5.x => Spring Boot 2.0.4.RELEASE Spring Cloud Edgware SR3 => ...

  2. 3.cassandra遇到内存占用过高的问题

    目前cssandra的内存分配如下: https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.ht ...

  3. vertx异步编程测试

    vertx是异步编程的框架,性能较高,开发简单.异步编程就是当一个请求来了,vertx将其交由一个事件进行处理,然后继续向下执行,等处理完成,返回结果,通知客户端.这是一个由服务端反向调用客户端的过程 ...

  4. 十四、springboot全局处理异常(@ControllerAdvice + @ExceptionHandler)

    1.@ControllerAdvice 1.场景一 在构建RestFul的今天,我们一般会限定好返回数据的格式比如: { "code": 0, "data": ...

  5. angular $scope.$watch

    在$scope内置的所有函数中,用得最多的可能就是$watch 函数了.当你的数据模型中某一部分发生变化时,$watch函数可以向你发出通知. 你可以监控单个对象的属性,也可以监控需要经过计算的结果( ...

  6. vs2015 相关

    VS2015一共有3个版本,Visual Studio Community(社区版).Visual Studio Professional(专业版).Visual Studio Enterprise( ...

  7. MVC备忘笔记

    1.增加样式 @Html.EditorFor(model => model.AssociationName, new { @class="inputtext input-220&quo ...

  8. SpringMyBatisDay02

    全篇概述:IOC    DI     参数值注入      注解依赖注入 1.Spring IOCIOC 全称Inversion Of Control,被翻译成控制反转控制反转指:程序中对象的获取方式 ...

  9. TestDriven.NET 怎么设置快捷键keyboard shortcut(转)

    TestDriven.NET 怎么设置快捷键keyboard shortcut 使用TestDriven.NET 测试的时候,觉得点击鼠标很麻烦是不是?嗯,我也觉得,那么我们来看看怎么设置它的快捷键把 ...

  10. java编译 Error: Could not find or load main class java执行包main方法

    在java源文件开头有包声明语句,编译的时候需要指定生成的class文件路径. 解决方法: javac -d your_path your_class.java 例如:javac -d . First ...