题意:非常清晰!

直接搞吧。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
const double pi = acos(-1.0); const int mod =9973; const int N = 20; struct asd{
LL a[N][N];
};
int n; asd mul(asd a,asd b)
{
asd ans;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
ans.a[i][j]=0;
for(int k=1;k<=n;k++)
{
ans.a[i][j]=(ans.a[i][j]+a.a[i][k]*b.a[k][j])%mod;
}
}
}
return ans;
}
asd quickmul(asd z,int g)
{
asd ans;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==j)
ans.a[i][j]=1;
else
ans.a[i][j]=0;
}
}
while(g)
{
if(g%2)
{
ans=mul(ans,z);
}
g/=2;
z=mul(z,z);
}
return ans;
} int main()
{
int t;
int i,j,k;
asd s;
scanf("%d",&t);
while(t--)
{
asd A;
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%lld",&A.a[i][j]);
}
}
s=quickmul(A,k);
LL ans=0; for(i=1;i<=n;i++)
{
ans+=s.a[i][i];
} printf("%lld\n",ans%mod);
}
return 0;
}

最新文章

  1. Yii2.0 对的一些简单的操作
  2. dataGridViewX和数据库的链接之dataGridViewX1.DataSource = ds.Tables[0];
  3. jmx : ClientCommunicatorAdmin Checker-run
  4. 从jQuery中学习来的另一种继承方式(技巧)
  5. 如何在ASP.Net中实现RSA加密
  6. 【iHMI43 4.3寸液晶模块】demo例程(版本1.02)发布
  7. 虚拟机centos配置ip
  8. 在Centos7上安装漏洞扫描软件Nessus
  9. Android手机开发者模式设置
  10. [jQuery编程挑战]007 切换数据表格的行列
  11. [Jquery] 操作html 不常用元素方法大全
  12. 依赖注入之Autofac使用总结
  13. iOS 微信消息拦截插件系列教程-附录(服务端成果展示)
  14. 一些常见的shell命令和git命令
  15. istio环境搭建for macbook
  16. 2019.4.1 JMeter中文乱码解决方案
  17. java调用dll/so文件
  18. FileReader &amp; Blob &amp; File
  19. bzoj千题计划200:bzoj3106: [cqoi2013]棋盘游戏
  20. boost boost::asio::read socket.read_some 区别

热门文章

  1. memcached优化方法
  2. SpringBoot学习之@SpringBootApplication注解
  3. BusHelper
  4. Alert提示框之后跳转指定页面
  5. asp对中文编码及解码,Decode和Encode中文网址处理
  6. bash shell parameter expansion
  7. Java,多个线程对同一个数据源的访问
  8. MapReduce ChainMapper/ChainReducer
  9. POJ2243 Knight Moves —— A*算法
  10. MYSQL初级学习笔记八:MySQL中常用的函数!(视频序号:初级_45-50)