51Nod-1032-骨牌覆盖 V2
来源:互联网 发布:淘宝我的发票在哪里看 编辑:程序博客网 时间:2024/06/07 01:02
ACM模版
描述
题解
数据弱化的一个题,原题是
代码
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>using namespace std;typedef long long ll;const int MOD = 1e9 + 7;const int MAXN = 1 << 5;ll dp[MAXN][MAXN];ll ret[MAXN][MAXN];ll tmp[MAXN][MAXN];int m, n = 3;void dfs(int col, int pre, int now){ if (col > n) { return ; } if (col == n) { dp[pre][now]++; return ; } dfs(col + 1, pre << 1, (now << 1) | 1); dfs(col + 1, (pre << 1) | 1, now << 1); dfs(col + 2, pre << 2 , now << 2);}void mul(ll ret[][MAXN], ll a[][MAXN], ll b[][MAXN]){ int t = 1 << n; for (int i = 0; i < t; i++) { for (int j = 0; j < t; j++) { ll tmp = 0; for (int k = 0; k < t; k++) { tmp += a[i][k] * b[k][j]; tmp %= MOD; } ret[i][j] = tmp; } }}int main(){ scanf("%d", &m); dfs(0, 0, 0); int t = 1 << n; for (int i = 0; i < t; i++) { ret[i][i] = 1; } m++; while (m) { for (int i = 0; i < t; i++) { for (int j = 0; j < t; j++) { tmp[i][j] = ret[i][j]; } } if (m & 1) { mul(ret, tmp, dp); } m = m >> 1; mul(tmp, dp, dp); for (int i = 0; i < t; i++) { for (int j = 0; j < t; j++) { dp[i][j] = tmp[i][j]; } } } cout << ret[0][t - 1] << endl; return 0;}
阅读全文
0 0
- 51Nod-1032-骨牌覆盖 V2
- 51nod 1033 骨牌覆盖v2
- 51nod 1033骨牌覆盖 V2
- 51Nod-1033-骨牌覆盖 V2
- 51nod 1033 骨牌覆盖 V2(矩阵快速幂)
- 51NOD 1031 骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51nod-1031 骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51nod-【1031 骨牌覆盖】
- 51Nod 1031 骨牌覆盖
- 51Nod 1031 骨牌覆盖
- 51nod 1031骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51nod 1031 骨牌覆盖
- 51Nod 1031 骨牌覆盖
- CCF-训练50题-NO.20-A+B和C比大小
- 【1701H1】【穆晨】【171110】连续第三十一天总结
- spring boot 使用spring AOP实现拦截器 修改包名后报错
- cf Educational Codeforces Round 32
- Java小白必须会的一道算法题
- 51Nod-1032-骨牌覆盖 V2
- Mysql 命令
- c++ 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
- Kaggle项目:Kobe Bryant Shot Selection(科比投篮选择)
- 排序算法
- struts 实现ajax校验用户名是否存在
- 5G超密集组网驱动光模块市场爆发
- opencv模板匹配笔记----C++练手项目
- 全新Linux服务器安装Nginx&PHP&MySQL环境