On my computer code::blocks run too, but the code can be AC, it is depressed.
Asked the great God, know that the parameters of the function is placed in the stack area, the structure is too large, the stack will explode, and then listen to the views of the great God with reference rewrite.
Portal: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1853
#include <stdio.h> #include <string.h> #include <stdlib.h>int len_matrix;int mod;double value[205]; struct matrix{double m[205][205];}; void Init_matrix (Matrix & tmp) {for (int. i=0;i<len_matrix;i++) {for (int j=0;j<len_matrix;j++) { if (I==J) tmp. M[I][J] = 1; else TMP. M[I][J] = 0; }}}void Debug_matrix (Matrix & tmp) {for (int. i=0;i<len_matrix;i++) {for (int j=0;j<len_matrix;j++) { printf ("%lf", tmp.) M[I][J]); } puts (""); }}void Multiply (Matrix & A1,matrix & A2,matrix & ans) {for (int. i=0;i<len_matrix;i++) {for (int j=0 ; j<len_matrix;j++) {ans. M[I][J] = 0; for (int k=0;k<len_matrix;k++) {ans. M[I][J] + = A1. M[i][k]*a2. M[K][J]; }}}}void Pow (Matrix & tmp,int Nl,matrix &ans) {Init_matrix (ans); Matrix TEMP1,TEMP2; while (NL) {if (nl&1) {temp1 = ans; MUltiply (Temp1,tmp,ans); } TEMP1 = tmp; TEMP2 = tmp; Multiply (temp1,temp2,tmp); NL/= 2; }}void Solve (Matrix & Tmp,int m) {matrix ans; Pow (Tmp,m,ans); Double Zans = 0; for (int i=0;i<len_matrix;i++) {Zans + = ans. M[I][LEN_MATRIX-1] * Value[i]; } printf ("%.0lf\n", Zans);} void Input () {int n,m; while (scanf ("%d%d", &n,&m), n+m) {Matrix tmp; Len_matrix = n; Init_matrix (TMP); for (int i=0;i<n;i++) {scanf ("%lf", value+i); } int k; scanf ("%d", &k); int TEMPI,TEMPJ; Double temprate; for (int i=0;i<k;i++) {scanf ("%d%d%lf", &tempi,&tempj,&temprate); Tmp. M[TEMPI][TEMPJ] + = temprate; Tmp. M[TEMPI][TEMPI]-= temprate; } Solve (Tmp,m); }}void File () {freopen ("a.in", "R", stdin); Freopen ("A.out", "w", stdout);} int main (void) {//file (); Input (); return 0;}
Zoj 2853 Evolution Matrix Fast Power