Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

World Final 签到题?G++过不了,换C++才能过?

Posted by vjubge4 at 2019-06-18 21:04:25 on Problem 1877
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator