http://acm.hdu.edu.cn/showproblem.php?pid=1203
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
struct f
{
int money;
double may;
}s[10001];
double p[10001];
int sum,n;
bool cmp(f a,f b)
{
if(a.money<b.money)return a.may<b.may;
return false;
}
double Max(double a,double b)
{
if(a<b)return b;
else return a;
}
double Offer()
{
int i,j;
fill(p,p+10001,0);
for(i=0;i<n;i++)
{
for(j=sum;j>=s[i].money;j--)
{
p[j]=Max(p[j],1-(1-p[j-s[i].money])*(1-s[i].may));
}
}
return p[sum];
}
int main()
{
int i;
while(cin>>sum>>n)
{
if(sum==0&&n==0)break;
for(i=0;i<n;i++)
{
cin>>s[i].money>>s[i].may;
}
sort(s,s+n,cmp);
printf("%.1lf%%\n",Offer()*100);
}
return 0;
}