这题真的有2500分吗。。。 难以置信。。。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 1e6 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); int n, k, a[], b[], dp[ << ];
bool ban[ << ];
LL dis[ << ]; inline void add(int& a, int b) {
a += b; if(a >= mod) a -= mod;
} int main() {
scanf("%d", &n);
for(int i = ; i < n; i++) scanf("%d", &a[i]);
scanf("%d", &k);
for(int i = ; i < k; i++) scanf("%d", &b[i]);
for(int S = ; S < ( << n); S++) {
for(int i = ; i < S; i++) {
if(S >> i & ) {
dis[S] = dis[S ^ ( << i)] + a[i];
break;
}
}
for(int i = ; i < k; i++) {
if(dis[S] == b[i]) {
ban[S] = true;
break;
}
}
}
dp[] = ;
for(int S = ; S < ( << n); S++) {
if(ban[S]) continue;
for(int i = ; i < n; i++) {
if(S >> i & ) {
add(dp[S], dp[S ^ ( << i)]);
}
}
}
printf("%lld\n", dp[( << n) - ]);
return ;
} /*
*/

Codeforces 327E Axis Walking 状压dp的更多相关文章

  1. CodeForces 327E Axis Walking(状压DP+卡常技巧)

    Iahub wants to meet his girlfriend Iahubina. They both live in Ox axis (the horizontal axis). Iahub ...

  2. codeforces Diagrams & Tableaux1 (状压DP)

    http://codeforces.com/gym/100405 D题 题在pdf里 codeforces.com/gym/100405/attachments/download/2331/20132 ...

  3. Codeforces 917C - Pollywog(状压 dp+矩阵优化)

    UPD 2021.4.9:修了个 typo,为啥写题解老出现 typo 啊( Codeforces 题目传送门 & 洛谷题目传送门 这是一道 *2900 的 D1C,不过还是被我想出来了 u1 ...

  4. Codeforces 79D - Password(状压 dp+差分转化)

    Codeforces 题目传送门 & 洛谷题目传送门 一个远古场的 *2800,在现在看来大概 *2600 左右罢( 不过我写这篇题解的原因大概是因为这题教会了我一个套路罢( 首先注意到每次翻 ...

  5. Codeforces 544E Remembering Strings 状压dp

    题目链接 题意: 给定n个长度均为m的字符串 以下n行给出字符串 以下n*m的矩阵表示把相应的字母改动成其它字母的花费. 问: 对于一个字符串,若它是easy to remembering 当 它存在 ...

  6. codeforces 21D. Traveling Graph 状压dp

    题目链接 题目大意: 给一个无向图, n个点m条边, 每条边有权值, 问你从1出发, 每条边至少走一次, 最终回到点1. 所走的距离最短是多少. 如果这个图是一个欧拉回路, 即所有点的度数为偶数. 那 ...

  7. Codeforces 895C - Square Subsets 状压DP

    题意: 给了n个数,要求有几个子集使子集中元素的和为一个数的平方. 题解: 因为每个数都可以分解为质数的乘积,所有的数都小于70,所以在小于70的数中一共只有19个质数.可以使用状压DP,每一位上0表 ...

  8. Codeforces ----- Kefa and Dishes [状压dp]

    题目传送门:580D 题目大意:给你n道菜以及每道菜一个权值,k个条件,即第y道菜在第x道后马上吃有z的附加值,求从中取m道菜的最大权值 看到这道题,我们会想到去枚举,但是很显然这是会超时的,再一看数 ...

  9. CodeForces 907E Party(bfs+状压DP)

    Arseny likes to organize parties and invite people to it. However, not only friends come to his part ...

随机推荐

  1. 基于Selenium的Web自动化框架增强篇

    在写完上一篇“基于Selenium的Web自动化框架”(http://www.cnblogs.com/AlwinXu/p/5836709.html)之后一直没有时间重新审视该框架,正好趁着给同事分享的 ...

  2. golang string int int64转换

    #string到int int,err:=strconv.Atoi(string) #string到int64 int64, err := strconv.ParseInt(string, 10, 6 ...

  3. HDFS2.0架构以及HA详解

    HDFS2.0概述 一背景,Hadoop1.0中HDFS和MapReduce在高可用,扩展性等方面存在问题    HDFS存在问题,1,NameNode单点故障,难以应用于在线场景.2,NameNod ...

  4. 【BUG】websphere找不到类或jar包冲突

    来自:http://liuwei1578.blog.163.com/blog/static/49580364200991572642653/ Jar包冲突问题是在大型Java软件开发中经常遇到的问题, ...

  5. mysql 架构~mgr具体细节分析

    一 简介:今天咱们来聊聊mgr的具体实现细节 二 关于多点写入的锁冲突问题以及处理:   certify模块主要负责检查事务是否允许提交,是否与其它事务存在冲突,如两个事务可能修改同一行数据.在单机系 ...

  6. Ubuntu/Debian 8 安装 Intel realsense 摄像头驱动

    ## Make Ubuntu/Debian Up-to-date1. sudo apt-get update && sudo apt-get upgrade && su ...

  7. Debian Linux Error “Driver 'pcspkr' is already registered, aborting...”

    问题: Error: Driver ‘pcspkr’ is already registered, aborting… 解决: [root@reistlin.com ~]# echo "bl ...

  8. phantomjs 下拉滚动条获取网页的全部源码

    //codes.js var system = require('system'); var fs = require("fs"); //console.log('Loading ...

  9. springboot系列十三、springboot集成swaggerUI

    一.Swagger介绍 Swagger能成为最受欢迎的REST APIs文档生成工具之一,有以下几个原因: Swagger 可以生成一个具有互动性的API控制台,开发者可以用来快速学习和尝试API. ...

  10. java项目中oracle配置说明

    配置信息: #oracle database settings jdbc.url::orcl jdbc.username=cognos_data jdbc.password=cognos_data j ...