最后一个点有没有人算出来是192.32的

P1016 [NOIP1999 提高组] 旅行家的预算

没办法了只能特判了
by courtesan @ 2019-02-14 14:48:02


``` //思路:到达每个站点的最小耗油量都等于在它一箱油的距离内 //所有站点的最小耗油量+到达该站点的耗油量 中最小的一个 #include<bits/stdc++.h> using namespace std; typedef long double ld; struct station { ld cost; ld pri;//分别代表从起点到该站的距离和该站的油价 }; vector<station> all(8); vector<ld> cost(8,1000000); ld d1,c,d2,p,n; int main() { cin>>d1>>c>>d2>>p>>n; all[0].cost=0,all[0].pri=p; all[n+1].cost=d1,all[n+1].pri=10000;//把起点和终点看作两个加油站并设置好 for(int i=1;i<=n;i++) cin>>all[i].cost>>all[i].pri; cost[0]=0; for(int i=1;i<=n+1;i++) {if(all[i].cost-all[i-1].cost>c*d2) {cout<<"No Solution";exit(0); } for(int j=0;j<i;j++) if(all[i].cost-all[j].cost<=c*d2) cost[i]=min(cost[i],cost[j]+(all[i].cost-all[j].cost)/d2*all[j].pri);//转移方程 } cout<<fixed<<setprecision(2)<<cost[n+1]; } ```
by courtesan @ 2019-02-14 14:54:58


@[courtesan](/space/show?uid=179441) 我我我
by ycyaw @ 2019-02-28 18:34:20


捞捞沉帖
by ycyaw @ 2019-02-28 18:34:42


计算没有很大的问题,你应该是贪心出来问题,之前我也出现过这种问题
by whwh @ 2019-06-07 07:57:33


+1
by 耶梦加得 @ 2019-07-09 16:21:39


+1
by z_y_z @ 2019-07-10 19:38:21


+1
by ysmlwudia @ 2019-08-12 10:12:17


|