题意:中文题
思路:求至少的话,就求都没有的情况,01背包
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 10005; int a[MAXN]; int ai,n,m; double f[MAXN],b[MAXN]; int main(){ while (scanf("%d%d",&n,&m) != EOF && n+m){ for (int i = 0; i < m; i++) scanf("%d%lf",&a[i],&b[i]); for (int i = 0; i <= n; i++) f[i] = 1.0; for (int i = 0; i < m; i++) for (int j = n; j >= a[i]; j--) f[j] = min(f[j],f[j-a[i]]*(1-b[i])); printf("%.1lf%%\n",(1-f[n])*100); } return 0; }