Problem1136--FatMouse's Trade

1136: FatMouse's Trade

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 32 MiB

Description

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.
The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.



翻译:

FatMouse 准备了 M 磅猫粮,打算用来和守卫仓库的猫交换他最喜欢的食物——JavaBean。

仓库里有 N 个房间。第 i 个房间里有 J[i] 磅 JavaBean,需要用 F[i] 磅猫粮来交换。FatMouse 不必一次性交换整个房间的 JavaBean,他可以按比例交换:如果他支付 F[i] × a% 的猫粮,就可以得到 J[i] × a% 的 JavaBean,其中 a 是一个实数。

现在他把这个任务交给你:请你计算他最多可以获得多少磅 JavaBean。





Input

The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. All integers are not greater than 1000.


翻译:

输入:
输入包含多组测试数据。每组数据的第一行包含两个非负整数 M 和 N。接下来有 N 行,每行包含两个非负整数 J[i] 和 F[i]。

当输入为两个 -1 时,表示输入结束。所有整数均不超过 1000。

Output

For each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain.
翻译:
输出:
对于每组测试数据,输出一行结果,为 FatMouse 能获得的 JavaBean 最大重量,结果保留 3 位小数。

Sample Input Copy

4 2
4 7
1 3
5 5
4 8
3 8
1 2
2 5
2 4
-1 -1

Sample Output Copy

2.286
2.500

Source/Category