文件名称:bb
-
所属分类:
- 标签属性:
- 上传时间:2016-05-31
-
文件大小:699byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
注意是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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.