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

Re:Notice~不愧是wordfinal啊。。。

Posted by like680623 at 2011-01-18 09:15:33 on Problem 1877
数据极其刁钻。。。大家小心。。。
贴出菜鸟代码供大家参考。。。
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;

int main()
{
	//ifstream cin("a.txt");
	int m, n, a = 0;
	double num[905];
	double mu[905];
	double value, x, y;
	while (cin>>m>>n)
	{
		if (!m && !n)return 0;
		mu[0] = mu[m * n] = 0;
		double temp = 0;
		double sum = 0;
		for (int i = 0; i < m * n; i++)
			cin>>num[i];
		cin>>value;
		value /= 100.0;
		sort(num, num + m * n);
		for (int i = 1; i <= m * n; i++)
		{
			if (mu[i - 1] >= value)break;
			mu[i] = mu[i - 1] + i * (num[i] - num[i - 1]);
			temp = i;
			sum += num[i - 1];
		}
		if (temp != 0)
			x = (sum + value) / temp;
		else x = 0;
		y = temp/ (m * n) * 100.0;
		if (a != 0)cout<<endl;
		printf("Region %d\n", ++a);
		printf("Water level is %.2lf meters.\n", x);
		printf("%.2lf percent of the region is under water.\n", y);
	}
	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