ProjectEuler215 Crack-free Walls
易知状态不会太多(\(3329\)个),直接搜一下,按照能不能连在后面建边,跑一遍dp即可
#include <bits/stdc++.h>
using namespace std;
struct S {
int cnt;
vector<int> s;
}a[5000];
int n, m = 10, L = 32;
vector<int> G[5000];
long long f[5000][15];
int tmp[100];
void dfs(int len, int cnt) {
if(len >= L) {
if(len > L) return ;
a[++n].cnt = cnt;
a[n].s.resize(cnt);
for(int i = 0; i < cnt; ++i) a[n].s[i] = tmp[i+1];
return ;
}
tmp[cnt+1] = 2;
dfs(len+2, cnt+1);
tmp[cnt+1] = 3;
dfs(len+3, cnt+1);
}
bool check(S &x, S &y) {
static int b[50];
memset(b, 0, sizeof b);
int sum = 0;
for(int i = 0; i < x.cnt; ++i) b[sum+x.s[i]]++, sum += x.s[i];
sum = 0;
for(int i = 0; i < y.cnt; ++i) b[sum+y.s[i]]++, sum += y.s[i];
for(int i = 2; i < L; ++i) if(b[i] > 1) return false;
return true;
}
int main() {
dfs(0, 0);
for(int i = 1; i <= n; ++i) {
f[i][1] = 1;
for(int j = 1; j < i; ++j) if(check(a[i], a[j])) G[i].push_back(j), G[j].push_back(i);
}
for(int i = 2; i <= m; ++i)
for(int u = 1; u <= n; ++u)
for(int j = 0; j < G[u].size(); ++j)
f[u][i] += f[G[u][j]][i-1];
long long ans = 0;
for(int i = 1; i <= n; ++i) ans += f[i][m];
printf("%lld\n", ans);
return 0;
}
ProjectEuler215 Crack-free Walls的更多相关文章
- reversing-Easy Crack
Easy Crack 程序启动后输入任意字符会显示一个MessageBox的Incorrect Password. 打开OllyDbg,载入程序后查找到目标字符串Incorrect Password, ...
- crack.vbs病毒,优盘里所有文件全变成快捷方式
去了一趟学校打印店,用优盘copy打印了点东西,当时在打印店电脑里打开优盘的时候里面就变成了快捷方式,但没怎么在意.回来之后在自己电脑上居然也这样了.网上一搜是中了crack.vbs病毒了.格式化优盘 ...
- MATLAB的crack安装小曲
MATLAB的crack安装小曲 本学期要学数学模型和数值分析,需要用MATLAB,便琢磨着装MATLAB.我同专业的同学会装MATLAB的crack,他是数学协会的理事长,平时爱吹牛,问他一个简单的 ...
- Walls(floyd POJ1161)
Walls Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7677 Accepted: 3719 Description ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- MITM to crack Https connections
Everybody knows that https is http over SSL, and https is a secure way for protecting confidential d ...
- CentOS下modelsim 10.2c install & crack
install: 1. install is easy to all : run install.linux 2 crack: this section is important: a. instal ...
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
Crack Mathmen TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take security ...
- 最短路(数据处理):HDU 5817 Ice Walls
Have you ever played DOTA? If so, you may know the hero, Invoker. As one of the few intelligence car ...
随机推荐
- C#进阶系列—WebApi
参考学习优秀博客地址:http://www.cnblogs.com/landeanfen/p/5177176.html
- 关于Angular+ngx-perfect-scrollbar自定义各大浏览器滚动条样式的解决方法
资料: http://manos.malihu.gr/jquery-custom-content-scroller/ (此项是结合Jquery使用的,在此并未采用) https://www.npmj ...
- restful规范与rest_framework
django两种开发模式: 一.前后端不分离项目 二.前后端分离项目 什么是restful规范? 在前后端不分离的项目中,网页所需要的数据可以直接通过模板渲染的方式传递到前端页面,并且可以很好的支持d ...
- POJ2594 Treasure Exploration【DAG有向图可相交的最小路径覆盖】
题目链接:http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS Memory Limit: 65536K T ...
- [CF1146D]Frog Jumping_exgcd_堆优化dij
Frog Jumping 题目链接:http://codeforces.com/contest/1146/problem/D 数据范围:略. 题解: 首先发现,如果$x\ge a +b$,那么所有的$ ...
- [转帖]Kubernetes中安装Helm及使用
Kubernetes中安装Helm及使用 2018年07月02日 17:41:09 灬勿忘丶心安 阅读数 3699更多 分类专栏: K8S 版权声明:本文为博主原创文章,遵循CC 4.0 BY-S ...
- InnoDB 中的锁实现
InnoDB 中的锁实现 原贴:InnoDB 锁系统及死锁检测实现分析 InnoDB 中,所有事务加的行锁通过一个全局的 hash 表 lock_sys 维护: /* The lock system ...
- springboot中配置文件使用1
1.表达方式:application.properties或者application.yml,这是已经约定成俗的文件,不用修改文件名,此文件为全局配置文件. 2.语法格式:yml或者yaml. a.基 ...
- ORACLE通过JOB定时创建序列
http://blog.csdn.net/cuihaiyang/article/details/7872982 因为业务需要每月需要增加一个序列,想到了使用job定时创建,每次创建一年的.写此job的 ...
- java7:核心技术与最佳实践读书笔记——对象生命周期
流程:字节码文件(.class) -> 类加载 -> 类链接 -> 类初始化 -> 对象初始化 -> 对象创建 -> 对象使用 -> 对象回收 . 1.Jav ...