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

写了直接交了,过了,但后来发现一个问题,求解

Posted by AB38017032 at 2012-08-01 19:42:03 on Problem 1018
#include <stdio.h>
#include <string.h>
int a[105];//代表n种设备的数量
int b[105][105][2];//b[][][0]代表某种设备的B值,b[][][1]代表某种设备的P值
int main()
{
	int test,t;
	int n;//需要的设备数量
	int i,j,k;
	int max,min,mat;
	int sump;//P的相加
	double result,tp;//tp记录结果
	scanf("%d",&test);
	for(t=0;t<test;t++)
	{
		max=1000000;
	    min=1000000;
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
	    mat=0;
		scanf("%d",&n);
		for(i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			for(j=1;j<=a[i];j++)
			{
				scanf("%d%d",&b[i][j][0],&b[i][j][1]);
			if(b[i][j][0]<min)  min=b[i][j][0];
			if(b[i][j][0]>mat)  mat=b[i][j][0];
			}
			if(max>mat) max=mat;
		}
		//printf("%d  %d  \n",min,max);
		tp=0.0;
		for(i=min;i<=max;i++)//i即为B,B固定,再寻找P
		{
			sump=0;
			for(j=1;j<=n;j++)
			{
                mat=1000000;
				for(k=1;k<=a[j];k++)//找出每一行的最小P
				{
					if(b[j][k][0]>=i && b[j][k][1]<mat)
						mat=b[j][k][1];
				}
				sump+=mat;
			}
			result=(i+0.0)/(sump+0.0);
			if(result>tp)
				tp=result;//result=tp;
		}
		printf("%.3lf\n",tp);
	}
	return 0;
}
//
//
for(i=min;i<=max;i++)这一句的时候好像没有判断i是属于所输入的所有的B的一个啊??还是我理解错了???????????

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