标签:span ++ eof ott 接下来 output lld The ace
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6490 Accepted Submission(s): 4817
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 using namespace std; 6 long long n,k; 7 void mul(long long wqw[10][10],long long tat[10][10]) 8 { 9 long long or2[10][10]; 10 memset(or2,0,sizeof(or2)); 11 for(int i = 0 ; i < n ; i++) 12 { 13 for(int j = 0 ; j < n ; j++) 14 { 15 for(int kk = 0 ; kk < n ;kk++) 16 { 17 or2[i][j]+=(wqw[i][kk]*(tat[kk][j]))%9973; 18 or2[i][j]%=9973; 19 } 20 } 21 } 22 memcpy(wqw,or2,sizeof(or2)); 23 } 24 void mulself(long long awa[10][10]) 25 { 26 long long or3[10][10]; 27 memset(or3,0,sizeof(or3)); 28 for(int i = 0; i < n ; i++) 29 { 30 for(int j = 0 ; j< n ; j++) 31 { 32 for(int kk = 0 ; kk < n ; kk++) 33 { 34 or3[i][j]+=((awa[i][kk])%9973)*((awa[kk][j])%9973)%9973; 35 or3[i][j]%=9973; 36 } 37 } 38 } 39 memcpy(awa,or3,sizeof(or3)); 40 } 41 int main() 42 { 43 int T; 44 scanf("%d",&T); 45 while(T--) 46 { 47 long long qwq[10][10],qaq[10][10]; 48 scanf("%lld%lld",&n,&k); 49 memset(qwq,0,sizeof(qwq)); 50 for(int i = 0 ; i < n ; i++) 51 { 52 for(int j = 0 ; j < n ; j++) 53 { 54 scanf("%lld",&qaq[i][j]); 55 if(i==j) 56 qwq[i][j]=1;//1单位矩阵 57 } 58 } 59 60 while(k) 61 { 62 if(k&1) 63 mul(qwq,qaq); 64 mulself(qaq); 65 k/=2; 66 } 67 long long sum=0; 68 for(int i = 0 ; i < n ; i++) 69 { 70 sum+=(qwq[i][i]%9973); 71 sum%=9973; 72 } 73 cout << sum %9973 << endl; 74 } 75 return 0; 76 }
标签:span ++ eof ott 接下来 output lld The ace
原文地址:https://www.cnblogs.com/MekakuCityActor/p/9008380.html