标签:title express min preview include text each tin osi
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 118 Accepted Submission(s): 79
1 //2017-09-10 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 #define LL long long 7 #define MAXN 100 8 9 using namespace std; 10 11 const int MOD = 998244353; 12 13 struct Matrix 14 { 15 LL a[MAXN][MAXN]; 16 int r, c; 17 }; 18 19 Matrix ori, res; 20 21 void init() 22 { 23 memset(res.a, 0, sizeof(res.a)); 24 res.r = 2; res.c = 2; 25 for(int i = 1; i <= 2; i++) 26 res.a[i][i] = 1; 27 ori.r = 2; ori.c = 2; 28 ori.a[1][1] = ori.a[1][2] = ori.a[2][1] = 1; 29 ori.a[2][2] = 0; 30 } 31 32 Matrix multi(Matrix x, Matrix y) 33 { 34 Matrix z; 35 memset(z.a, 0, sizeof(z.a)); 36 z.r = x.r, z.c = y.c; 37 for(int i = 1; i <= x.r; i++) 38 { 39 for(int k = 1; k <= x.c; k++) 40 { 41 if(x.a[i][k] == 0) continue; 42 for(int j = 1; j<= y.c; j++) 43 z.a[i][j] = (z.a[i][j] + (x.a[i][k] * y.a[k][j]) % MOD) % MOD; 44 } 45 } 46 return z; 47 } 48 void Matrix_mod(int n) 49 { 50 while(n) 51 { 52 if(n & 1) 53 res = multi(ori, res); 54 ori = multi(ori, ori); 55 n >>= 1; 56 } 57 printf("%lld\n", res.a[1][2]-1 % MOD); 58 } 59 60 int main() 61 { 62 int k; 63 while(scanf("%d", &k) != EOF) 64 { 65 init(); 66 k++; 67 Matrix_mod(2*k+1); 68 } 69 return 0; 70 }
标签:title express min preview include text each tin osi
原文地址:http://www.cnblogs.com/Penn000/p/7502280.html