Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
World Final 签到题?G++过不了,换C++才能过?#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int oo = 0x3f3f3f3f; int W, H; int field[31][31]; int T; int main() { int c = 0; while(true) { scanf("%d %d", &H, &W); if(W == 0 && H == 0){ break; } for(int i = 0; i < H; i ++) { for(int j = 0; j < W; j ++) { scanf("%d", &field[i][j]); } } scanf("%d", &T); double lb = -oo, ub = oo; for(int i = 0; i < 100; i ++) { double mid = (lb + ub) / 2; double V = 0; for(int i = 0; i < H; i ++) { for(int j = 0; j < W; j ++) { if(mid > field[i][j]){ V += 10 * 10 * (mid - field[i][j]); } } } if(V > T){ ub = mid; } else { lb = mid; } } int ctr = 0; for(int i = 0; i < H; i ++) { for(int j = 0; j < W; j ++) { if(lb > field[i][j]){ ctr ++; } } } printf("Region %d\n", ++c); printf("Water level is %.2f meters.\n", lb); printf("%.2f percent of the region is under water.\n\n", (100.0 * ctr) / (1.0 * W * H) ); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator