文件名称:bb
介绍说明--下载内容均来自于网络,请自行研究使用
注意是n位数!
思路:
对于给的n都会包含有四种状态
0、7和9的个数都是奇数
1、7是奇数,9是偶数
2、7是偶数,9是奇数
3、7是偶数,9是偶数
显然状态3是我们要状态,但是他们之间是可以互相转移的
所以对于每次添加一个空位放数字,建立转移矩阵
| 3 1 1 0 |
| 1 3 0 1 |
| 1 0 3 1 |
| 0 1 1 3 |
初始状态为 (0,0,0,1)
然后就是n次方了~利用矩阵快速幂
最后ans.mat[0][3]就是答案了-Note that n is the number of bits!
Ideas:
For given n will contain four states
Number 0,7 and 9 are odd
1,7 is an odd number, an even number 9
2,7 is an even number, an odd number 9
3,7 is an even number, an even number 9
Obviously we want to state 3 is a state, but they can be transferred between each other
So for every time you add a space to put numbers to establish transfer matrix
| 3 1 1 0 |
| 1 3 0 1 |
| 1 0 3 1 |
| 0 1 1 3 |
The initial state is (0,0,0,1)
And then the n-th power of matrix fast power ~
Finally ans.mat [0] [3] is the answer
思路:
对于给的n都会包含有四种状态
0、7和9的个数都是奇数
1、7是奇数,9是偶数
2、7是偶数,9是奇数
3、7是偶数,9是偶数
显然状态3是我们要状态,但是他们之间是可以互相转移的
所以对于每次添加一个空位放数字,建立转移矩阵
| 3 1 1 0 |
| 1 3 0 1 |
| 1 0 3 1 |
| 0 1 1 3 |
初始状态为 (0,0,0,1)
然后就是n次方了~利用矩阵快速幂
最后ans.mat[0][3]就是答案了-Note that n is the number of bits!
Ideas:
For given n will contain four states
Number 0,7 and 9 are odd
1,7 is an odd number, an even number 9
2,7 is an even number, an odd number 9
3,7 is an even number, an even number 9
Obviously we want to state 3 is a state, but they can be transferred between each other
So for every time you add a space to put numbers to establish transfer matrix
| 3 1 1 0 |
| 1 3 0 1 |
| 1 0 3 1 |
| 0 1 1 3 |
The initial state is (0,0,0,1)
And then the n-th power of matrix fast power ~
Finally ans.mat [0] [3] is the answer
(系统自动生成,下载前可以参看下载内容)
下载文件列表
鏂板缓鏂囨湰鏂囨。 (2).txt