// // main.cpp // uva11429 // // Created by New_Life on 16/8/4. // Copyright © 2016年 chenhuan001. All rights reserved. // #include <iostream> #include <math.h> #include <string> #include <stdio.h> #include <algorithm> using namespace std; #define N 1010 #define eps 1e-12 long double g[N]; int main(int argc, const char * argv[]) { int r,n; while(scanf("%d%d",&r,&n) && !(r==0&&n==0)) { for(int i=0;i<n;i++) { int a,b; scanf("%d%d",&a,&b); g[i] = (long double)a/b; } long double sum = 1.0; long double dr = 1; long double up = 0; long double ans = 1.0; long double preans; do { long double tmp=0; dr *= r; up *= r; for(int i=0;i<n;i++) { long long tmpi = (long long)(g[i]*dr+eps); g[i] -= (long double)tmpi/dr; up += tmpi; } preans = ans; ans += (dr-up)/dr; //ans += sum; }while(ans-preans>1e-10); printf("%.6Lf\n",ans); } return 0; } /* 100 3 1 3 1 3 1 3 2 4 1 4 1 4 1 4 1 4 2 3 1 3 1 3 1 3 10 2 1 2 1 2 */
//用long double 才过的...