Miemeng problem found
The mouth that is not clear ~ ~
The code!
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define N 222 5 using namespace std; 6 const int Mod=2009; 7 struct JZ{ 8 int lines,cols; 9 int A[N][N]; 10 JZ(){ 11 lines=cols=0; 12 memset(A,0,sizeof A); 13 } 14 void set_JZ(int l,int c){ 15 lines=l,cols=c; 16 } 17 void out(){ 18 for (int i=1;i<=lines;i++){ 19 for (int j=1;j<=cols;j++){ 20 printf("%d ",A[i][j]); 21 } 22 puts(""); 23 } 24 } 25 };JZ a,b; 26 int n,tim; 27 JZ operator * (JZ a,JZ b){ 28 JZ c; 29 c.lines=min(a.lines,b.lines),c.cols=min(a.cols,b.cols); 30 int len=a.lines+b.lines-c.lines; 31 for (int i=1;i<=c.lines;i++){ 32 for (int j=1;j<=c.cols;j++){ 33 for (int k=1;k<=len;k++){ 34 c.A[i][j]+=a.A[i][k]*b.A[k][j]; 35 c.A[i][j]%=Mod; 36 } 37 } 38 } 39 return c; 40 } 41 JZ ppow(JZ a,int b){ 42 JZ ans;ans.set_JZ(9*n,9*n); 43 for (int i=0;i<9*n;i++){ 44 ans.A[i][i]=1; 45 } 46 while(b){ 47 if(b&1)ans=ans*a; 48 a=a*a; 49 b>>=1; 50 } 51 return ans; 52 } 53 inline bool ian(const char ch){ 54 if(ch>='0'&&ch<='9')return 1; 55 return 0; 56 } 57 char st[22]; 58 intmain () { 59 (. A in () * B * in . ()) OUT (); 60 A. in (), B. in (), (A * B). OUT (); // where two different line output QAQ 61 is return 0 ; 62 is }
In fact: (Updated)
It would seem to enter b, enter a, thereby using the commutative law does not hold the matrix. Ooo, ooo ~ ~ ~
I'm not out of tune ~ ~
Gone