用数组dp来存放没被录取的最小概率;
初始值为1;
#include <iostream>
#include <stdio.h>#include <string.h>
using namespace std;
double dp[100000];int main()
{
double p[10000];
int money[10000];
int tot,n,i,j;
while(scanf("%d%d",&tot, &n)&&(tot || n))
{ for(i = 0 ; i <= tot ; i++)
dp[i] = 1;
for( i = 0; i < n; i++)
scanf("%d%lf",&money[i] ,&p[i]);
for( i = 0 ; i < n; i++)
for(j = tot; j >= money[i]; j--)
{dp[j] = min(dp[j],dp[j-money[i]]*(1-p[i]));
}
printf("%.1lf%%\n",100*(1-dp[tot]));
}
}