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

为什么我这个代码C++能过G++不能?

Posted by zhuye930 at 2012-01-15 15:51:07 on Problem 1877
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<fstream>
using namespace std;
#define LEN 1000
//#define cin fin
//ifstream cin("1.txt");
int main (void)
{
    int n,m,start,maxn,num,sum,i;
    int region[LEN];
    double water,remain;
    num=1;
    while(cin>>n>>m&&(n||m)){
        for(i=0;i<n*m;i++)
        cin>>region[i];
        cin>>maxn;
        sort(region,region+n*m);
        start=region[0];
        sum=0;
        for(i=1;i<n*m;i++)
        if(sum+(region[i]-start)*i*100<=maxn){
            sum+=(region[i]-start)*i*100;
            start=region[i];
        }
        else
        break;
        remain=maxn-sum;
        water=region[i-1]+remain/(double(i)*100.0);
        for(i=0;region[i]<water&&i<n*m;i++);
        printf("Region %d\n",num++);
        printf("Water level is %.2f meters.\n",water);
        printf("%.2f percent of the region is under water.\n\n",100*i/double(n*m));
    }
    return 0;
}

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