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,求解释#include <iostream> using namespace std; int num[110]; struct mac { double b; double p; double bp; }v[110][110],cv; int main() { int t,et,i,j; scanf("%d",&t); while(t--) { scanf("%d",&et); for(i = 0;i < et;i++) { scanf("%d",&num[i]); for(j = 0;j < num[i];j++) { scanf("%lf%lf",&v[i][j].b,&v[i][j].p); v[i][j].bp = v[i][j].b / v[i][j].p; } } //dp cv.b = v[0][0].b; cv.p = v[0][0].p; cv.bp = cv.b / cv.p; for(i = 1;i < num[0];i++) { if(cv.bp < v[0][i].bp) { cv.b = v[0][i].b; cv.p = v[0][i].p; cv.bp = cv.b / cv.p; } } for(i = 1;i < et;i++) { mac ccv; ccv.b = cv.b > v[i][0].b ? v[i][0].b : cv.b; ccv.p = cv.p + v[i][0].p; ccv.bp = ccv.b / ccv.p; for(j = 1;j < num[i];j++) { if(v[i][j].b >= cv.b && cv.b / (cv.p + v[i][j].p) > ccv.bp) { ccv.b = cv.b; ccv.p = v[i][j].p + cv.p; ccv.bp = cv.b / (cv.p + v[i][j].p); } if(v[i][j].b < cv.b && v[i][j].b / (cv.p + v[i][j].p) > ccv.bp) { ccv.b = v[i][j].b; ccv.p = v[i][j].p + cv.p; ccv.bp = v[i][j].b / (cv.p + v[i][j].p); } } cv.b = ccv.b; cv.p = ccv.p; cv.bp = ccv.bp; } printf("%.3lf\n",cv.bp); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator