#include
#include
#include
#include
using namespace std;
class room
{
public:
int javabin;
int catfood;
double per;
public:
room(){}
void renew(int j,int c)
{
javabin=j;
catfood=c;
per=(double)j/c;
}
bool operator<(room b)
{
return per
void show() //用来测试的
{
cout<
};
room ROOM[1005];
int main()
{
int M,N;
int ja,fo;
while(cin>>M>>N)
{
if(M==-1&&N==-1)break;
double sum=0;
for(int i=0;i
cin>>ja>>fo;
ROOM[i].renew(ja,fo);
}
sort(ROOM,ROOM+N);
// for(int i=0;i
// ROOM[i].show();
// }
for(int i=N-1;i>=0;i--)
{
if(ROOM[i].catfood<=M)
{
sum+=ROOM[i].javabin;
M-=ROOM[i].catfood;
}
else
{
sum+=M*ROOM[i].per;
break; //已经是没有猫粮了
}
}
printf("%.3lf\n",sum);
}
return 0;
}