| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
能想到的数据都正确,为啥wa啊,路过帮看下吧g++编译
#include <iostream>//communication sys
#include <iomanip>
int band = 2147483647;
int total = 0;
float de = 0.0000001;
using namespace std;
void process(int *b,int *c, int m){//寻找单个设备的b/c的最大值,记录b-band和c-price
float temp = 0.0;
int bt,ct;
for(int i = 0; i < m; i++){
//cout<<temp<<b[i]*1.0/c[i];
if(b[i]*1.0/c[i]>temp){
temp = b[i]*1.0/c[i];
bt = b[i];
ct = c[i];
}
else if(b[i]*1.0/c[i]<temp+de&&b[i]*1.0/c[i]>temp-de&&b[i]<bt){//比值相同时去较小的band
temp = b[i]*1.0/c[i];
bt = b[i];
ct = c[i];
}
}
if(bt<band) band = bt;
total +=ct;
}
int main()
{
int t;
int n;
int m;
float maxbc[10];
cin >> t;
for(int i = 0; i < t; i++){
cin >> n;
for(int j = 0; j < n; j++){
cin >> m;
int b[m],c[m];
for(int k = 0; k < m; k++)cin >> b[k] >> c[k];
process(b,c,m);//一个设备处理一次
}
maxbc[i] = band*1.0/total;
band = 2147483647;
total = 0;
}
for(int s =0; s < t; s++)
cout <<fixed <<setprecision(3)<< maxbc[s] <<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator