Problem : 1203 ( I NEED A OFFER! ) Judge Status : Accepted
RunId : 2594060 Language : G++ Author : huwenbiao
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
RunId : 2594060 Language : G++ Author : huwenbiao
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
/***************************************************************\
*Author: 小呼
*Created Time: Mon 12 Jul 2010 04:46:55 PM CST
*File Name: main.cpp
*Description: 01背包问题。
\***************************************************************/
//*========================*Head File*========================*\\
#include<iostream>
#include<stdio.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
int n,m,a;
double b,f[10001];
//*=======================*Main Program*=======================*//
using namespace std;
int main(){
//freopen("input","r",stdin);
while(scanf("%d%d",&n,&m)!=EOF&&(n||m)){
memset(f,0,sizeof(f));
for(int i=0;i<m;++i){
scanf("%d%lf",&a,&b);
for(int i=n;i>=a;--i)
f[i]=max(f[i],f[i-a]+b-f[i-a]*b);//状态转移方程跟常规的不一样
}
printf("%.1lf%%\n",f[n]*100);
}
return 0;
}