user-0 提问: 一些题连意思都没看懂。。求大神

回复:
user: user-1
content: 3   取对数

user: user-2
content: 再供参考：//地上一大块由长M米，宽N米共M×N个小块组成的高低不平的区域，地面高度为0，每小块内部是平的，其高度为0～9米不等. //一场大雨过后，这块区域的积水共多少立方米？ //假设水只会流到正东、正南、正西、正北相邻的且高度较低的小块里; //而不会流到东北、东南、西北、西南相邻的且高度较低的小块里。 #include <stdio.h> #include <time.h> #include <stdlib.h> #define M 10 #define N 10 int a[M+4][N+4];//地面高度 int w[M+4][N+4];//水面高度 int sp=0; int xs[(M+4)*(N+4)]; int ys[(M+4)*(N+4)]; int xx,yy; int x,y; int i,h; int tw; void push(int py,int px) { //  printf("%03d %d,%d\n",sp,py,px);     ys[sp]=py;     xs[sp]=px;     if (sp<(M+4)*(N+4)-1) {         sp=sp+1;     } else {         printf("stack overflow!\n");         exit(1);     } } void pop(void) {     sp=sp-1;     yy=ys[sp];     xx=xs[sp]; } int check(int cy,int cx,int ch) {     if (a[cy][cx]<=ch && w[cy][cx]>ch) return 1;     else return 0; } void floodfilling(int hh) {     push(1,1);     while (1) {         if (sp<=0) break;//         pop();         if (check(yy,xx,hh)) {             w[yy][xx]=hh;             if (check(yy-1,xx  ,hh)) push(yy-1,xx  );             if (check(yy  ,xx+1,hh)) push(yy  ,xx+1);             if (check(yy  ,xx-1,hh)) push(yy  ,xx-1);             if (check(yy+1,xx  ,hh)) push(yy+1,xx  );         }     }     for (y=0;y<=M+3;y++) {         for (x=0;x<=N+3;x++) {             printf("%d%d ",a[y][x],w[y][x]);         }         printf("\n");     }     for (x=0;x<=N+3;x++) printf("---");     printf("hh=%d\n",hh); } void main() {     //最外圈增加一圈高度9的小块     for (i=0;i<=M+3;i++) {a[i][0]=9;a[i][N+3]=9;}     for (i=0;i<=N+3;i++) {a[0][i]=9;a[M+3][i]=9;}      //次外圈增加一圈高度0的小块     for (i=1;i<=M+2;i++) {a[i][1]=0;a[i][N+2]=0;}     for (i=1;i<=N+2;i++) {a[1][i]=0;a[M+2][i]=0;}      srand(time(NULL));     for (y=2;y<=M+1;y++) {         for (x=2;x<=N+1;x++) {             a[y][x]=rand()%10;//初始地面高度         }     }      for (y=0;y<=M+3;y++) {         for (x=0;x<=N+3;x++) {             w[y][x]=9;//初始水面高度9         }     }      printf("当前每小块地面高度水面高度\n",tw);     for (y=0;y<=M+3;y++) {         for (x=0;x<=N+3;x++) {             printf("%d%d ",a[y][x],w[y][x]);         }         printf("\n");     }     for (x=0;x<=N+3;x++) printf("---");     printf("hh=9\n");      for (h=8;h>=0;h--) floodfilling(h);//检查水面高度8到0      tw=0;     for (y=2;y<=M+1;y++) {         for (x=2;x<=N+1;x++) {             tw+=(w[y][x]-a[y][x]>0)?w[y][x]-a[y][x]:0;         }     }     printf("共积水%d立方米\n",tw); } //当前每小块地面高度水面高度 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 09 09 09 09 09 09 09 09 09 09 09 09 99 //99 09 89 49 39 79 79 69 49 79 09 69 09 99 //99 09 19 29 59 39 39 99 09 59 49 79 09 99 //99 09 09 39 59 79 99 29 39 09 69 39 09 99 //99 09 79 59 89 59 09 39 09 49 79 49 09 99 //99 09 09 69 19 99 39 39 19 59 99 29 09 99 //99 09 29 19 39 99 79 29 39 89 79 99 09 99 //99 09 29 29 39 29 89 69 19 89 39 99 09 99 //99 09 99 99 89 79 49 79 89 69 39 09 09 99 //99 09 29 19 29 69 39 89 39 39 99 19 09 99 //99 09 79 39 19 39 19 29 19 89 69 79 09 99 //99 09 09 09 09 09 09 09 09 09 09 09 09 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=9 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 08 08 08 08 08 08 08 08 08 08 08 08 99 //99 08 88 48 38 78 78 68 48 78 08 68 08 99 //99 08 18 28 58 38 38 99 08 58 48 78 08 99 //99 08 08 38 58 78 99 28 38 08 68 38 08 99 //99 08 78 58 88 58 08 38 08 48 78 48 08 99 //99 08 08 68 18 99 38 38 18 58 99 28 08 99 //99 08 28 18 38 99 78 28 38 88 78 99 08 99 //99 08 28 28 38 28 88 68 18 88 38 99 08 99 //99 08 99 99 88 78 48 78 88 68 38 08 08 99 //99 08 28 18 28 68 38 88 38 38 99 18 08 99 //99 08 78 38 18 38 18 28 18 88 68 78 08 99 //99 08 08 08 08 08 08 08 08 08 08 08 08 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=8 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 07 07 07 07 07 07 07 07 07 07 07 07 99 //99 07 88 47 37 77 77 67 47 77 07 67 07 99 //99 07 17 27 57 37 37 99 07 57 47 77 07 99 //99 07 07 37 57 77 99 27 37 07 67 37 07 99 //99 07 77 57 88 57 07 37 07 47 77 47 07 99 //99 07 07 67 17 99 37 37 17 57 99 27 07 99 //99 07 27 17 37 99 77 27 37 88 77 99 07 99 //99 07 27 27 37 27 88 67 17 88 37 99 07 99 //99 07 99 99 88 77 47 77 88 67 37 07 07 99 //99 07 27 17 27 67 37 88 37 37 99 17 07 99 //99 07 77 37 17 37 17 27 17 88 67 77 07 99 //99 07 07 07 07 07 07 07 07 07 07 07 07 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=7 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 06 06 06 06 06 06 06 06 06 06 06 06 99 //99 06 88 46 36 77 77 66 46 77 06 66 06 99 //99 06 16 26 56 36 36 99 06 56 46 77 06 99 //99 06 06 36 56 77 99 26 36 06 66 36 06 99 //99 06 77 56 88 56 06 36 06 46 77 46 06 99 //99 06 06 66 16 99 36 36 16 56 99 26 06 99 //99 06 26 16 36 99 77 26 36 88 77 99 06 99 //99 06 26 26 36 26 88 66 16 88 36 99 06 99 //99 06 99 99 88 77 46 77 88 66 36 06 06 99 //99 06 26 16 26 66 36 88 36 36 99 16 06 99 //99 06 77 36 16 36 16 26 16 88 66 77 06 99 //99 06 06 06 06 06 06 06 06 06 06 06 06 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=6 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 05 05 05 05 05 05 05 05 05 05 05 05 99 //99 05 88 45 35 77 77 66 45 77 05 66 05 99 //99 05 15 25 55 35 35 99 05 55 45 77 05 99 //99 05 05 35 55 77 99 25 35 05 66 35 05 99 //99 05 77 55 88 55 05 35 05 45 77 45 05 99 //99 05 05 66 15 99 35 35 15 55 99 25 05 99 //99 05 25 15 35 99 77 25 35 88 77 99 05 99 //99 05 25 25 35 25 88 66 15 88 35 99 05 99 //99 05 99 99 88 77 45 77 88 66 35 05 05 99 //99 05 25 15 25 66 35 88 35 35 99 15 05 99 //99 05 77 35 15 35 15 25 15 88 66 77 05 99 //99 05 05 05 05 05 05 05 05 05 05 05 05 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=5 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 04 04 04 04 04 04 04 04 04 04 04 04 99 //99 04 88 44 34 77 77 66 44 77 04 66 04 99 //99 04 14 24 55 35 35 99 04 55 44 77 04 99 //99 04 04 34 55 77 99 24 34 04 66 34 04 99 //99 04 77 55 88 55 04 34 04 44 77 44 04 99 //99 04 04 66 14 99 34 34 14 55 99 24 04 99 //99 04 24 14 34 99 77 24 34 88 77 99 04 99 //99 04 24 24 34 24 88 66 14 88 34 99 04 99 //99 04 99 99 88 77 44 77 88 66 34 04 04 99 //99 04 24 14 24 66 34 88 34 34 99 14 04 99 //99 04 77 34 14 34 14 24 14 88 66 77 04 99 //99 04 04 04 04 04 04 04 04 04 04 04 04 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=4 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 03 03 03 03 03 03 03 03 03 03 03 03 99 //99 03 88 44 33 77 77 66 44 77 03 66 03 99 //99 03 13 23 55 35 35 99 04 55 44 77 03 99 //99 03 03 33 55 77 99 24 34 04 66 33 03 99 //99 03 77 55 88 55 04 34 04 44 77 44 03 99 //99 03 03 66 13 99 34 34 14 55 99 23 03 99 //99 03 23 13 33 99 77 24 34 88 77 99 03 99 //99 03 23 23 33 23 88 66 14 88 33 99 03 99 //99 03 99 99 88 77 44 77 88 66 33 03 03 99 //99 03 23 13 23 66 33 88 33 33 99 13 03 99 //99 03 77 33 13 33 13 23 13 88 66 77 03 99 //99 03 03 03 03 03 03 03 03 03 03 03 03 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=3 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 02 02 02 02 02 02 02 02 02 02 02 02 99 //99 02 88 44 33 77 77 66 44 77 02 66 02 99 //99 02 12 22 55 35 35 99 04 55 44 77 02 99 //99 02 02 33 55 77 99 24 34 04 66 33 02 99 //99 02 77 55 88 55 04 34 04 44 77 44 02 99 //99 02 02 66 13 99 34 34 14 55 99 22 02 99 //99 02 22 12 33 99 77 24 34 88 77 99 02 99 //99 02 22 22 33 23 88 66 14 88 33 99 02 99 //99 02 99 99 88 77 44 77 88 66 33 02 02 99 //99 02 22 12 22 66 33 88 33 33 99 12 02 99 //99 02 77 33 12 33 12 22 12 88 66 77 02 99 //99 02 02 02 02 02 02 02 02 02 02 02 02 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=2 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 01 01 01 01 01 01 01 01 01 01 01 01 99 //99 01 88 44 33 77 77 66 44 77 01 66 01 99 //99 01 11 22 55 35 35 99 04 55 44 77 01 99 //99 01 01 33 55 77 99 24 34 04 66 33 01 99 //99 01 77 55 88 55 04 34 04 44 77 44 01 99 //99 01 01 66 13 99 34 34 14 55 99 22 01 99 //99 01 22 12 33 99 77 24 34 88 77 99 01 99 //99 01 22 22 33 23 88 66 14 88 33 99 01 99 //99 01 99 99 88 77 44 77 88 66 33 01 01 99 //99 01 22 12 22 66 33 88 33 33 99 11 01 99 //99 01 77 33 11 33 11 22 11 88 66 77 01 99 //99 01 01 01 01 01 01 01 01 01 01 01 01 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=1 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //99 00 00 00 00 00 00 00 00 00 00 00 00 99 //99 00 88 44 33 77 77 66 44 77 00 66 00 99 //99 00 11 22 55 35 35 99 04 55 44 77 00 99 //99 00 00 33 55 77 99 24 34 04 66 33 00 99 //99 00 77 55 88 55 04 34 04 44 77 44 00 99 //99 00 00 66 13 99 34 34 14 55 99 22 00 99 //99 00 22 12 33 99 77 24 34 88 77 99 00 99 //99 00 22 22 33 23 88 66 14 88 33 99 00 99 //99 00 99 99 88 77 44 77 88 66 33 00 00 99 //99 00 22 12 22 66 33 88 33 33 99 11 00 99 //99 00 77 33 11 33 11 22 11 88 66 77 00 99 //99 00 00 00 00 00 00 00 00 00 00 00 00 99 //99 99 99 99 99 99 99 99 99 99 99 99 99 99 //------------------------------------------hh=0 //共积水40立方米

user: user-0
content: 引用 1 楼 fefe82 的回复:3   取对数 懂了，谢谢。这方法会记住的。。

user: user-0
content: 引用 4 楼 user-3 的回复:1) 贪心, 排序后, 从头开始找相同数字, 比如样3 1 2 3 1 ==> 1 1 2 3 3 , 1找到1变成2, 再找2, 配对后变成3, 第一次去掉1123,  2) 面积比算一下 (a+d)/a =(b+c)/b *(a+b+c+d)/(a+b) ==> d=ac(ab+2b^2+bc)/(b^3-abc) 这两题搞定了，太厉害了！多谢！

user: user-3
content: 1) 贪心, 排序后, 从头开始找相同数字, 比如样3 1 2 3 1 ==> 1 1 2 3 3 , 1找到1变成2, 再找2, 配对后变成3, 第一次去掉1123,  2) 面积比算一下 (a+d)/a =(b+c)/b *(a+b+c+d)/(a+b) ==> d=ac(ab+2b^2+bc)/(b^3-abc)

user: user-2
content: 4参考下面：#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <graphics.h> int xs[10000]; int ys[10000]; int i=0,xx,yy; int fc,bc; void push(int x,int y) {     xs[i]=x;     ys[i]=y;     if (i<10000-1) {         i=i+1;     } else {         printf("stack overflow!\n");         exit(1);     } } void pop(void) {     i=i-1;     xx=xs[i];     yy=ys[i]; } int check(int x,int y) {     int c;      c=getpixel(x,y); /* 获取当前点的颜色 */     return ((c!=bc)&&(c!=fc));/* 如果颜色为边界色或填充色则不填充 */ } void seedfilling(int x,int y,int fill_color,int boundary_color) {     fc=fill_color;     bc=boundary_color;     push(x,y);     while (1) {         if (i<=0) return;         pop();         if (check(xx,yy)) {             putpixel(xx, yy, 14);getch();  /* 加上这行显示当前填充状态 */              putpixel(xx, yy, fill_color); /* 画点 */              if (check(xx-1,yy  )) push(xx-1,yy  );             if (check(xx  ,yy+1)) push(xx  ,yy+1);             if (check(xx  ,yy-1)) push(xx  ,yy-1);             if (check(xx+1,yy  )) push(xx+1,yy  );             /* 去掉下面四句就是四连通 */             if (check(xx-1,yy-1)) push(xx-1,yy-1);             if (check(xx-1,yy+1)) push(xx-1,yy+1);             if (check(xx+1,yy-1)) push(xx+1,yy-1);             if (check(xx+1,yy+1)) push(xx+1,yy+1);         }     } } void main() {     int a,b,color;     int gdriver = DETECT, gmode, errorcode;     int poly[10];      initgraph(&gdriver, &gmode, "d:\\bc\\bgi");     a=150;     b=140;     color=4;     poly[0]=110;/* 第一个点的x坐标以及y坐标 */     poly[1]=110;     poly[2]=200;/* 第二点 */     poly[3]=105;     poly[4]=170;/* 第三点 */     poly[5]=120;     poly[6]=150;/* 第四点 */     poly[7]=170;     poly[8]=110;/* 多边形的起点与终点一样 */     poly[9]=110;     drawpoly(5,poly);/* 显示各点连接起来的多边形 */      /* 保证边界对八连通是封闭的 */     setviewport(0,1,600,300,0);     drawpoly(5,poly);/* 显示各点连接起来的多边形 */     setviewport(1,0,600,300,0);     drawpoly(5,poly);/* 显示各点连接起来的多边形 */     setviewport(1,1,600,300,0);     drawpoly(5,poly);/* 显示各点连接起来的多边形 */      /* 恢复默认viewport */     setviewport(0,0,600,300,0);      seedfilling(a,b,color,15);  /* 种子填充多边形 */      getch();     closegraph(); }

user: user-0
content: 引用 1 楼 fefe82的回复:3   取对数 那这位大神请问具体该怎么解决？