HDU 2570 迷瘴
2013-04-04 16:26
363 查看
浓度按照从小到大排序,一直累加到超过W就可以停了,该死的比例转来转去头都晕了.
#include <iostream> #include <algorithm> #include <memory.h> #include <cstdio> using namespace std; const int maxn=110; int P[maxn],n,V,W; int main(){ int t; scanf("%d",&t); while (t--) { scanf("%d%d%d",&n,&V,&W); for (int i=0;i<n;++i)scanf("%d",&P[i]); sort(P,P+n); int ansV=0,sum=0; double mul=100.0/V,ansP=0.0;; for (int i=0;i<n;++i) { sum+=P[i]; double t=sum/((double)(i+1)*V*mul); if(t<=W/100.0&&ansV<(i+1)*V){ ansV=(i+1)*V; ansP=t; }else break; } printf("%d %.2lf\n",ansV,ansP); } return 0; }
相关文章推荐
- HDU 2570 迷瘴
- hdu 2570 迷瘴
- HDU2570——迷瘴
- [HDU](2570)迷瘴 ---贪心
- HDU 2570 迷瘴(贪心)
- hdu2570 迷瘴
- hdu 2570 迷瘴 低级贪心
- hdu 2570 迷瘴
- HDU-2570 迷瘴 (贪心)
- HDU 2570 迷瘴
- 文章标题 HDU 2570 : 迷瘴(贪心)
- HDU 2570 迷瘴 (贪心)
- HDU 2570 迷瘴(贪心)
- hdu 2570 迷瘴
- --hdu 2570 迷瘴(贪心)
- HDU 2570:迷瘴
- hdu 2570 迷瘴(贪心)
- HDU 2570 迷瘴 (贪心)
- hdu 2570 迷瘴
- HDU - 2570 迷瘴(贪心)