标签:
Description
Input
Output
Sample Input
10 3 4 0.1 4 0.2 5 0.3 0 0
Sample Output
44.0%
#include<cstdio> #include<cstring> #include<iostream> #include<stdlib.h> #include<vector> #include<queue> #include<cmath> using namespace std; #define maxn 25055 #define oo 0x3f3f3f int n; int k; double dp[maxn]; struct point { int a; double b; } p[maxn]; double max(double x,double y) { if(x>y) return x; else return y; } int main() { int t,n,m; while(scanf("%d%d", &n,&m),n||m) { memset(dp, 0, sizeof(dp)); for(int i=1; i<=m; i++) { scanf("%d%lf",&p[i].a,&p[i].b); } for(int i=1; i<=m; i++) { for(int j=n; j>=p[i].a; j--) { dp[j] = max(dp[j],1-(1-dp[j-p[i].a])*(1-p[i].b)); } } double ans = dp[n]*100; printf("%.1f",ans); printf("%%\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/biu-biu-biu-/p/5743575.html