当前位置:网站首页>矩阵快速幂
矩阵快速幂
2022-07-15 10:27:00 【51CTO】
问题 G: 强
时间限制: 1 Sec 内存限制: 128 MB
[提交] [状态]
题目描述
Lh:粉兔你教我一下抽屉原理吧
Clz:就是给你一个长度为 n 的序列,每个数只能取 0,1,2,那你连续取三个数必然有两个相等……
Lh:等等你梭啥,再说一遍
Clz:……emmm 当我没说
Marser:就是一个序列,对于每一个连续三元组都要满足其中至少有两个相等
现在粉兔问你:有多少个长度为 n 的序列满足粉兔的要求?请对 19260817 取模。
输入
一行一个正整数n(3≤n≤1018)。
输出
一行一个整数,含义如题。
样例输入 Copy
4
样例输出 Copy
51
提示
51 种序列如下:
[0,0,0,0],[0,0,0,1],[0,0,0,2],[0,0,1,0],[0,0,1,1],[0,0,2,0],[0,0,2,2],[0,1,0,0],[0,1,0,1],[0,1,1,0],[0,1,1,1],[0,1,1,2],[0,2,0,0],[0,2,0,2],[0,2,2,0],[0,2,2,1],[0,2,2,2],[1,0,0,0],[1,0,0,1],[1,0,0,2],[1,0,1,0],[1,0,1,1],[1,1,0,0],[1,1,0,1],[1,1,1,0],[1,1,1,1],[1,1,1,2],[1,1,2,1],[1,1,2,2],[1,2,1,1],[1,2,1,2],[1,2,2,0],[1,2,2,1],[1,2,2,2],[2,0,0,0],[2,0,0,1],[2,0,0,2],[2,0,2,0],[2,0,2,2],[2,1,1,0],[2,1,1,1],[2,1,1,2],[2,1,2,1],[2,1,2,2],[2,2,0,0],[2,2,0,2],[2,2,1,1],[2,2,1,2],[2,2,2,0],[2,2,2,1],[2,2,2,2]。
思路:矩阵快速幂
推这个东西的过程可以和大家分享一下
其实也没什么 就是用计算机跑for循环 毕竟计算机算大数据时比我算的快而准。
最后得到一组数 21 51 123 197…
都是 3的倍数除以三得到
7 17 41 99 …
可以得到 an=2*an-1+an-2;
当时忘了怎么用矩阵快速幂了(也就是不会,嘻嘻~~)。
这样我们就可以构造了。我也不太懂是怎么构造的 ,这个简单 还是巧了我一下凑出来了,就是
这样身下的就简单了。
边栏推荐
- 001 hierarchy selector
- 001一个内部类的实例拿到所在外部类的实例(反射)
- MFC pet store information management system
- 对接企业微信,客户关系管理也可以很简单!
- mongoose 模糊查询 (单条件与多条件)
- Room:又要写业务代码了?看看我吧,给你飞一般的感觉!
- 这可是全网网工基础知识最详细的整理,没有之一
- Matlab底层源代码实现图像腐蚀,膨胀操作(与Halcon效果一致)
- Introduction and basic use of container image construction tool kaniko (googlecontainertools/kaniko)
- [kapok] Summer Challenge # Hongmeng small game project Sudoku
猜你喜欢
随机推荐
Chrome realizes automated testing: recording and playback web page actions
H5 page in wechat evokes applet & app
Excel fast l count the number of red data in all lines [commonly used in teaching]
018.代理模式结和Filter做的一个屏蔽敏感词汇
从0开始的 TypeScriptの十四:内置工具类型
Introduction and basic use of container image construction tool kaniko (googlecontainertools/kaniko)
Guys, the capture delay of flick CDC Oracle is particularly high. Is there any optimization method
Pytorch(二)——PyTorch的主要组成模块
浅谈 Slack Channel 支持的一些提高工作效率的特性
Room:又要写业务代码了?看看我吧,给你飞一般的感觉!
Mongoose fuzzy query (single condition and multi condition)
Configure scan packages based on annotations
关于Kubernetes中kubelet的一些笔记
002 descendant selector
001一个内部类的实例拿到所在外部类的实例(反射)
mongoose 模糊查询 (单条件与多条件)
Detailed installation steps of mysql5.6 version
对接企业微信,客户关系管理也可以很简单!
002简述类加载过程(1)
JMeter 21 day clock in day04








