传送门

模板不解释。

——代码

 #include <cstdio>
#include <cstring>
#define LL long long int n;
LL k;
const int p = 1e9 + ; struct Matrix
{
LL a[][];
Matrix()
{
memset(a, , sizeof(a));
}
}; inline Matrix operator * (const Matrix x, const Matrix y)
{
Matrix ans;
int i, j, k;
for(i = ; i < n; i++)
for(j = ; j < n; j++)
for(k = ; k < n; k++)
ans.a[i][j] = (ans.a[i][j] + x.a[i][k] * y.a[k][j]) % p;
return ans;
} int main()
{
int i, j;
Matrix ans, trs;
scanf("%d %lld", &n, &k);
for(i = ; i < n; i++) ans.a[i][i] = ;
for(i = ; i < n; i++)
for(j = ; j < n; j++)
scanf("%lld", &trs.a[i][j]);
while(k)
{
if(k & ) ans = ans * trs;
trs = trs * trs;
k >>= ;
}
for(i = ; i < n; i++)
{
for(j = ; j < n; j++) printf("%d ", ans.a[i][j]);
puts("");
}
return ;
}

最新文章

  1. welcome-file-list设置问题之css,js文件无法加载
  2. web程序员该学习什么
  3. Windows下使用命令行启动php
  4. iOS开发——项目实战总结&amp;数据持久化分析
  5. 关于版本号:alpha、beta、rc、stable
  6. Tomacat服务器的安装和配置
  7. C++中 _itoa_s方法简介
  8. 工控主板对ISO7816智能卡标准的支持
  9. effective c++ 条款18 make interface easy to use correctly and hard to use incorrectly
  10. jQuery DataTable 删除数据后重新加载
  11. hibernate切换数据源
  12. 在CentOS 7.3 中安装 NVIDIA GT730 显卡驱动
  13. qnx gpio
  14. Git使用过程中的问题
  15. 【HDU 4343】Interval query(倍增)
  16. Android开发中常见的设计模式(四)——策略模式
  17. jmeter 连接 MySql
  18. Linux_CentOS-服务器搭建 &lt;三&gt; 补充
  19. Qt入门之基础篇 ( 一 ) :Qt4及Qt5的下载与安装
  20. android笔记:Service

热门文章

  1. HBase Region Assign流程详解
  2. ajax post 提交数据到服务端时中文乱码解决方法
  3. fastDFS shiro权限校验 redis FreeMark页面静态化
  4. Java线程-线程的基本状态
  5. Matlab基础之单元数组和结构数组
  6. 套接字、UDP通信、TCP通信、TCP/IP协议簇
  7. 数据库系统概论(1)——Chap. 1 Introduction
  8. Java中文乱码处理
  9. hdfs深入:07、hdfs的文件的读取过程
  10. JFinal怎么更改项目服务的端口