Common BoardHEYYYY CAN ANYONE HELP!!!!!!!! HAS NOONE SOLVED "BOXES"? My source : #include <stdio.h> #define UNDEFINED 0 #define MAXBOX 22 #define MAXR 16 #define MAXB 16 long double ways[MAXBOX][MAXR][MAXB]; int box,red,blue; FILE *f; void init(void) { int i,j,k; f = stdin; // f = fopen(fin,"r"); fscanf(f,"%d %d %d",&box,&red,&blue); // fclose(f); for (i=1;i<=box;i++) for (j=0;j<=red;j++) for (k=0;k<=red;k++) ways[i][j][k]=UNDEFINED; for (i=0;i<=red;i++) for (j=0;j<=blue;j++) ways[0][i][j]=1; } long double solve(int boxes,int r,int b) { int i,j; long double sum=0; if (ways[boxes][r][b]!=UNDEFINED) return ways[boxes][r][b]; for (i=0;i<=r;i++) for (j=0;j<=b;j++) { sum+=solve(boxes-1,r-i,b-j); } ways[boxes][r][b]=sum; return ways[boxes][r][b]; } int main(void) { init(); f = stdout; // f = fopen(fout,"w"); solve(box,red,blue); fprintf(f,"%0.0Lf\n",ways[box][red][blue]); return 0; } It works on my PC on all tests. Does it on yours too? AND ALSO - What compiler does timus use? This problem is very easy.Why don't you ask me?(Email to:"hyz12345678@163.com") > My source : > > #include <stdio.h> > > #define UNDEFINED 0 > #define MAXBOX 22 > #define MAXR 16 > #define MAXB 16 > > long double ways[MAXBOX][MAXR][MAXB]; > int box,red,blue; > FILE *f; > > void init(void) { > int i,j,k; > f = stdin; > // f = fopen(fin,"r"); > fscanf(f,"%d %d %d",&box,&red,&blue); > // fclose(f); > for (i=1;i<=box;i++) > for (j=0;j<=red;j++) > for (k=0;k<=red;k++) > ways[i][j][k]=UNDEFINED; > for (i=0;i<=red;i++) > for (j=0;j<=blue;j++) > ways[0][i][j]=1; > } > > long double solve(int boxes,int r,int b) { > int i,j; > long double sum=0; > if (ways[boxes][r][b]!=UNDEFINED) return ways[boxes][r][b]; > for (i=0;i<=r;i++) > for (j=0;j<=b;j++) { > sum+=solve(boxes-1,r-i,b-j); > } > ways[boxes][r][b]=sum; > return ways[boxes][r][b]; > } > > int main(void) { > init(); > f = stdout; > // f = fopen(fout,"w"); > solve(box,red,blue); > fprintf(f,"%0.0Lf\n",ways[box][red][blue]); > return 0; > } > > > It works on my PC on all tests. Does it on yours too? > > > AND ALSO - What compiler does timus use? What's wrong with your email box?I sent letters to you for times,for I always got "Undelieved letter returned". > My source : > > #include <stdio.h> > > #define UNDEFINED 0 > #define MAXBOX 22 > #define MAXR 16 > #define MAXB 16 > > long double ways[MAXBOX][MAXR][MAXB]; > int box,red,blue; > FILE *f; > > void init(void) { > int i,j,k; > f = stdin; > // f = fopen(fin,"r"); > fscanf(f,"%d %d %d",&box,&red,&blue); > // fclose(f); > for (i=1;i<=box;i++) > for (j=0;j<=red;j++) > for (k=0;k<=red;k++) > ways[i][j][k]=UNDEFINED; > for (i=0;i<=red;i++) > for (j=0;j<=blue;j++) > ways[0][i][j]=1; > } > > long double solve(int boxes,int r,int b) { > int i,j; > long double sum=0; > if (ways[boxes][r][b]!=UNDEFINED) return ways[boxes][r][b]; > for (i=0;i<=r;i++) > for (j=0;j<=b;j++) { > sum+=solve(boxes-1,r-i,b-j); > } > ways[boxes][r][b]=sum; > return ways[boxes][r][b]; > } > > int main(void) { > init(); > f = stdout; > // f = fopen(fout,"w"); > solve(box,red,blue); > fprintf(f,"%0.0Lf\n",ways[box][red][blue]); > return 0; > } > > > It works on my PC on all tests. Does it on yours too? > > > AND ALSO - What compiler does timus use? |