#include <stdio.h> #include <string.h> #include <queue> using namespace std; #define M 1002 struct node { int j,f; node(int _j,int _f) { j = _j; f = _f; } friend bool operator < (const node a,const node b) { return 1.0 * a.j / a.f < 1.0 * b.j / b.f; } }; priority_queue<node> q; int main(int argc, char* argv[]) { #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int m,n,Ji,Fi; double s; while(scanf("%d%d",&m,&n) + m + n) { while(!q.empty()) { q.pop(); } while(n--) { scanf("%d%d",&Ji,&Fi); q.push(node(Ji,Fi)); } s = 0; while(m > 0 && !q.empty()) { if(m >= q.top().f) s += q.top().j; else s += 1.0 * m / q.top().f * q.top().j; m -= q.top().f; q.pop(); } printf("%.3lf ",s); } return 0; }