矩阵快速幂2 3*n铺方格】的更多相关文章

#include <iostream> #include <cstdlib> #include <cstring> #include <queue> #include <cstdio> #include <algorithm> #include <map> #include <time.h> #include <ext/pb_ds/assoc_container.hpp> #include <…
#include <iostream> #include <cstdlib> #include <cstring> #include <queue> #include <cstdio> #include <algorithm> #include <map> #include <time.h> #include <ext/pb_ds/assoc_container.hpp> #include <…
由于方块最多涉及3行,于是考虑将每两行状压起来,dfs搜索每种状态之间的转移. 这样一共有2^12种状态,显然进行矩阵快速幂优化时会超时,便考虑减少状态. 进行两遍bfs,分别为初始状态可以到达的状态,和可以到达终止状态的状态. 同时出现在两次bfs中的状态即为有效状态,一共有141种. 这样就可以跑出来了. 未加矩阵快速幂 50分 ..,..] of longint= ((-,,),(-,,),(,,),(,,),(-,,),(-,,),(,,),(-,,)); dy:..,..] of lo…
首先建立矩阵,给每个格子编号,然后在4*4的格子中把能一步走到的格子置为1,然后乘n次即可,这里要用到矩阵快速幂 #include<iostream> #include<cstdio> using namespace std; const int mod=1e9+7; long long n,ans; struct qwe { long long a[5][5]; qwe operator * (qwe b) { qwe c; for(long long i=1;i<=4;i…
题目链接:传送门 题目: 石头游戏 0x30「数学知识」例题 描述 石头游戏在一个 n 行 m 列 (≤n,m≤) 的网格上进行,每个格子对应一种操作序列,操作序列至多有10种,分别用0~9这10个数字指明. 操作序列是一个长度不超过6且循环执行.每秒执行一个字符的字符串.每秒钟,所有格子同时执行各自操作序列里的下一个字符.序列中的每个字符是以下格式之一: 数字0~:表示拿0~9个石头到该格子. NWSE:表示把这个格子内所有的石头推到相邻的格子,N表示上方,W表示左方,S表示下方,E表示右方.…
<题目链接> <转载于 >>> > 题目大意: 让你用1*2规格的地毯去铺4*n规格的地面,告诉你n,问有多少种不同的方案使得地面恰好被铺满且地毯不重叠.答案对1000000007取模. 解题分析: 看到题目所给n的数据这么大,就知道肯定存在递推公式,至于递推公式的具体的分析过程  >>>大牛博客.求出递推公式后,由于数据太大,所以我们利用矩阵快速幂来加速.当然,如果比赛的时候想不到递推公式,我们也可以通过搜素得到前面的几组数据,然后在通过高斯消…
题目链接:传送门 描述石头游戏在一个 $n$ 行 $m$ 列 ($1 \le n,m \le 8$) 的网格上进行,每个格子对应一种操作序列,操作序列至多有 $10$ 种,分别用 $0 \sim 9$ 这 $10$ 个数字指明.操作序列是一个长度不超过 $6$ 且循环执行.每秒执行一个字符的字符串.每秒钟,所有格子同时执行各自操作序列里的下一个字符.序列中的每个字符是以下格式之一:数字 $0 \sim 9$:表示拿 $0 \sim 9$ 个石头到该格子.$NWSE$:表示把这个格子内所有的石头推…
题目链接 Description Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and each block can be paint red, blue, gree…
Covering Bob's school has a big playground, boys and girls always play games here after school. To protect boys and girls from getting hurt when playing happily on the playground, rich boy Bob decided to cover the playground using his carpets. Meanwh…
Problem J. Wiki with 35Input file: standard input Time limit: 1 secondOutput file: standard output Memory limit: 256 megabytes从前,有一对夫妻生了五胞胎,这对夫妻为了让这五兄弟比较容易让老师记得,分别给他们取名"1"."3". "5". "7". "9".而"3"…