UVAlive 7361 Immortal Porpoises(矩阵快速幂)
来源:互联网 发布:如何申请域名 编辑:程序博客网 时间:2024/06/05 20:35
题目地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5383
思路:
type arr=array[1..2,1..2] of int64;var x,p:int64; a,b,c,w:arr; cas,i,t:longint;procedure mul(var a,b,c:arr);var i,j,k,n:longint;begin n:=2; fillchar(w,sizeof(w),0); for i:=1 to n do for j:=1 to n do for k:=1 to n do w[i][j]:=(w[i][j]+a[i][k]*b[k][j]) mod p; for i:=1 to n do for j:=1 to n do c[i][j]:=w[i][j];end;begin readln(cas); p:=1000000000; for i:=1 to cas do begin read(t); readln(x); a[1,1]:=0;a[1,2]:=1;a[2,1]:=0;a[2,2]:=0; b[1,1]:=0;b[1,2]:=1;b[2,1]:=1;b[2,2]:=1; while (x<>0) do begin if x mod 2=1 then mul(a,b,a); x:=x div 2; mul(b,b,b); end; write(t); write(' '); writeln(a[1][1]); end;end.
0 0
- UVALive 7361 Immortal Porpoises (矩阵快速幂)
- UVAlive 7361 Immortal Porpoises(矩阵快速幂)
- 【纽约】-C- Immortal Porpoises(矩阵)
- UVALive 7361(矩阵快速幂)
- uvaLive7361-Immortal Porpoises-斐波那契
- UvaLive 3704 Cellular Automaton (矩阵快速幂)
- UVALive 6184_One-Dimensional Cellular Automaton(矩阵快速幂)
- poj3070(矩阵快速幂,矩阵乘法)
- UVA10655矩阵快速幂(构造矩阵)
- 快速幂,矩阵快速幂(模板)
- 快速幂(矩阵快速幂)
- 快速矩阵快速幂
- 矩阵相关(研究总结,矩阵,矩阵快速幂)
- 矩阵快速幂(模板)
- hdu2604(矩阵快速幂)
- hdu4968(矩阵快速幂)
- hdu5015(矩阵快速幂)
- Evolution(矩阵快速幂)
- Vim代码补全插件——YouCompleteMe安装说明
- spring—Bean配置
- text-align:justify和display:inline-block
- Android studio常见故障排除--ADB Connection Error
- 全栈工程师--通往架构师之路
- UVAlive 7361 Immortal Porpoises(矩阵快速幂)
- sql sum合计某一列的值
- IDEA 调试 Hadoop程序
- mac os ssh -X
- LSSVM(Least Squares SVM)与SVR(支持向量回归)
- 多态+this的一个小题
- 超级管理员 卸载应用 清除数据 锁屏
- DFS 模板
- 汉诺塔问题