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

不知道为什么老是WA。请大侠帮忙看看。

Posted by chhaya at 2009-07-01 11:17:40 on Problem 1018
#include <stdio.h>
//#include <conio.h>
typedef struct {
    int a;  //bandwidth
    int b;  //price
	float ab;  // B/P
}manu;
int main()
{
    int t, n, mi, i, j, price, bw;
    float bp;
    manu manufa[120][120];
    manu max[120];
 //   freopen("1018.dat", "r", stdin);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        i = 0;
        price = 0;
        bw = 99999999;
        while(i<n)
        {
            scanf("%d", &mi);
            max[i].ab = 0;
            for(j=0; j<mi; j++)
            {
                 scanf("%d%d", &manufa[i][j].a, &manufa[i][j].b);
				 if(manufa[i][j].b == 0)
				 {
					 manufa[i][j].ab = manufa[i][j].a*1.0;
				 }
				 else {manufa[i][j].ab = manufa[i][j].a * 1.0 / manufa[i][j].b;}
                 if(max[i].ab < manufa[i][j].ab)
                     max[i] = manufa[i][j];			//找出性价比最大的
            }
            price += max[i].b;     //求总价
            if(max[i].a < bw)
                bw = max[i].a;    //性价比最大的中的最小带宽
			i++;
        }
        bp = bw*1.0 / price;     // B/P
        printf("%.3f\n", bp);
    }
  //  getch();
    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