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#实现工作日和休息日(包括法定节假日)的计算
转自:http://www.cnblogs.com/yuan-chong/p/HolidayHelper.html 一.开发背景: 最近在公司开发的系统中,需要计算工作日,就是给出一个采购周期(n天) ...
- kindeditor的配置jsp版
1.将kindeditor资源下载下来,点击这里下载: 2.将资源解压,因为是jsp版本所以只需要保留jsp的文件即可,最终目录为下图 3.在所给的jsp的demo中做配置 注意:demo.jsp中引 ...
- Nginx部署前后端分离的单页应用配置
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...
- jQuery报错:Uncaught TypeError: _this.attr is not a function
问题:想通过延时把置灰的按钮再次复原,代码如下: $("#sendEmailCode").on("click", function() { var _this ...
- 题目12 打印1到最大的n位数
///////////////////////////////////////////////////////////////////////////////////// // 2.打印1到最大的n位 ...
- dl in image process
deep learning目前为止无论在分类还是检测上,都是整体的处理,而不会出现像sift这样的局部特征,这个问题或许如果能克服掉,能让检测效果更进一大步.
- Mysql定时备份[Windows]
基于mysql5.6.39版本 一.备份脚本 1.windows环境创建批处理文件 @echo off rem ******MySQL backup start****** set mysqlHome ...
- springboot+eureka+mybatis+mysql环境下报504 Gateway Time-out
1.test环境下的数据库配置的 driver和url有问题, 在工程日志中的表现是不能打印出最新的日志,在部署前的日志能看到报错:
- 微信小程使用getCurrentPages函数操作父级数据
微信小程使用getCurrentPages函数操作父级数据 let pages = getCurrentPages(); let prevPage = pages[pages.length - 2]; ...
- ECMAScript中的原型继承
//ECMAScript中的原型继承//ECMAScript中的继承主要是依靠原型链实现的.(关于原型链的介绍,详见<高三>6.3.1章节 P162) //本文示例主要为了说明SubTyp ...