HDU1203-I NEED A OFFER!

http://acm.hdu.edu.cn/showproblem.php?pid=1203

#include<cstdio>
#include<algorithm>
using namespace std;
double dp[10005];
int main(void)
{
    int n,m,ai,i,j;
    double bi;
    while(scanf("%d%d",&n,&m),n||m)
    {
        for(i=0;i<=n;i++)
           dp[i]=0;
        while(m--)
        {
            scanf("%d%lf",&ai,&bi);
            for(i=n;i>=ai;i--)
               dp[i]=max(dp[i],(1-(1-dp[i-ai])*(1-bi)));
        }    
        printf("%.1lf%%\n",dp[n]*100);
    }    
    return 0;
}
posted @ 2012-08-31 09:55  Yogurt Shen  阅读(118)  评论(0编辑  收藏  举报