#include<stdio.h> #include<stdlib.h> #include<string.h> #include<string> #include<algorithm> #define maxn 30+5 using namespace std; int main(){ int m,n,total,sum,t,flag,num=0; int a[maxn][maxn],ss[maxn*maxn]; double k,x,z; while(scanf("%d%d",&m,&n)==2){ if(m==0&&n==0) break; num++; sum=0,t=0,flag=1; memset(a,0,sizeof(a)); for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]); sum+=a[i][j]; ss[t++]=a[i][j]; } } sort(ss,ss+t); scanf("%d",&total); z=n*m; //z代表方格数 k=total/100.00; while(flag==1){ x=(k+sum)/z; if(x<ss[t-1]){ sum-=ss[t-1]; t--; z--; }else{ flag=0; printf("Region %d\n",num); printf("Water level is %.2lf meters.\n",x); k=z/(n*m)*100; printf("%.2lf percent of the region is under water.\n",k); printf("\n"); } } } return 0; }
时间: 2024-11-01 20:53:37