#include<bits/stdc++.h>
using namespace std;
int n,js,m[20],r[20];
double ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>m[i];
    for(int i=1;i<=n;i++) cin>>r[i];
    for(int i=1;i<=720720;i++)
       for(int j=1;j<=n;j++)
           if(i%m[j]==r[j])
{js++;
break;
}
    ans=1.0*js/720720;
    printf("%.6lf",ans);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:36777216")
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <sstream>
#include <utility>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <fstream>

using namespace std;
typedef long long long64;
typedef unsigned long long ulong64;
const int INF = 1e9;
const long64 ONEBIT = 1ULL;

int main()
{
	int n;
	cin >> n;
	vector<int> m(n), r(n);
	for (int i = 0; i < n; i++) {
	    cin >> m[i];
	}
	for (int i = 0; i < n; i++) {
	    cin >> r[i];
	}
	int loses(0), wins(0);
	for (int d = 0; d < 5e6; d++) {
	    bool lose = false;
    	for (int i = 0; i < n; i++) {
    	    if (d % m[i] == r[i]) {
    	        lose = true;
    	    }
    	}
    	if (lose) {
    	    loses++;
    	} else {
    	    wins++;
    	}
	}
    cout << (double) loses / (loses + wins);

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 10, inf = 2e9 + 1;

int n, m, a[maxn], b[maxn];

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    int sum = 1;
    for (int i = 0; i < n; i++)
        cin >> a[i], sum = sum * a[i] / __gcd(sum, a[i]);
    for (int i = 0; i < n; i++)
        cin >> b[i];
    int ans = 0;
    for (int i = 0; i < sum; i++){
        bool is = 0;
        for (int j = 0; j < n && !is; j++)
            if (i % a[j] == b[j])
                is = 1;
        if (is)
            ans++;
    }
    cout << setprecision(10) << (double)ans / sum;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <complex>
#include <iterator>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <deque>

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define FOR(x, b, e) for(int x = b; x <= (e); ++x)
#define FORD(x, b, e) for(int x = b; x >= (e); --x)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define VAR(v, n) typeof(n) v = (n)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define PB push_back
#define ST first
#define ND second
#define MP make_pair
#define PF push_front

int n,r[30],m[30];
long double ans;
long double l,mi;

int main()
{
	cin>>n;
	REP(i,n)
	{
		cin>>m[i];
	}
	REP(i,n)
	{
		cin>>r[i];
	}
	l=0.0;
	REP(i,1000000/2)
	{
		REP(p,n)
		{
			if((i%m[p])==r[p])
			{
				l++;
				break;
			}
		}
	}
	mi=(1000000.0)/(2.0);
	cout<<fixed;
	cout.precision(5);
	cout<<(l/mi);
}

#include<bits/stdc++.h>
using namespace std;
int n,sum,m[17],r[17];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&m[i]);
    for(int i=1;i<=n;i++) scanf("%d",&r[i]);
    for(int i=1;i<=720720;i++)
       for(int j=1;j<=n;j++)
           if(i%m[j]==r[j]){sum++;break;}
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 25
int ans,n;
int m[N],r[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&m[i]);
	for(int j=1;j<=n;++j)
		scanf("%d",&r[j]);
	for(int i=1;i<=1000000;++i)
		for(int j=1;j<=n;++j)
			if(i%m[j]==r[j]){
				++ans;
				break;
			}
	double ans2=1.0*ans/1000000;
	printf("%.6lf",ans2);
	return 0;
}

// wo hao cai a
#include<bits/stdc++.h>

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}
int m[20];
int r[20];

int main(){
    int n = inp();
    for(int i = 1; i <= n; i++)
        m[i] = inp();
    for(int i = 1; i <= n; i++)
        r[i] = inp();
    int ans = 0;
    for(int i = 0; i <= 5000000; i++){
        bool flg = false;
        for(int j = 1; j <= n; j++)
            if(i % m[j] == r[j]){
                flg = true;
                break;
            }
        if(flg)
            ans++;
    }
    // printf("%d\n", ans);
    printf("%.10lf", (double)ans / 5000000.00);
}

//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ll long long
#define ull unsigned long long
#define File(a) freopen((string(a)+string(".in")).c_str(),"r",stdin),freopen((string(a)+string(".out")).c_str(),"w",stdout)
template<class T1>void read(T1 &r_e_a_d);
template<class T1>void write(T1 w_r_i_t_e);
int n,sx,m[20],r[20];
int main() {
	read(n);
	for(int i=1; i<=n; i++)
		read(m[i]);
	for(int i=1; i<=n; i++)
		read(r[i]);
	for(int i=1; i<=720720; i++) {
		for(int j=1; j<=n; j++)
			if(i%m[j]==r[j]) {
				sx++;
				break;
			}
	}
	double ans=1.0*sx/720720;
	printf("%.6lf",ans);
	return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
	T1 k=0;
	char ch=getchar();
	int flag=1;
	while(!isNum(ch)) {
		ch=getchar();
		if(ch=='-') {
			flag=-1;
		}
	}
	while(isNum(ch)) {
		k=(k<<1)+(k<<3)+ch-'0';
		ch=getchar();
	}
	r_e_a_d=flag*k;
}
template<class T1>void write(T1 w_r_i_t_e) {
	if(w_r_i_t_e<0) {
		putchar('-');
		write(-w_r_i_t_e);
	} else {
		if(w_r_i_t_e<10) {
			putchar(w_r_i_t_e+'0');
		} else {
			write(w_r_i_t_e/10);
			putchar((w_r_i_t_e%10)+'0');
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
int lcm(int a,int b){
return a*(b/__gcd(a,b));
}

int main()
{
    int m=1,cnt=0;
    for(int i=2;i<17;i++){
        m=lcm(m,i);
    }
    vector<bool>ex(m+1);
   int  n,mx,tmp=0;
   cin>>n;
   vector<int>v1(n),v2(n);
   for(int i=0;i<n;i++){
    cin>>v1[i];
   }
    for(int i=0;i<n;i++){
    cin>>v2[i];
   }
    for(int i=0;i<n;i++){
        for(int j=v2[i];j<=m;j+=v1[i])ex[j]=true;
    }
    for(int i=0;i<=m;i++){
        if(ex[i])cnt++;
    }
    double ans=((double)cnt)/(double)(m);
    printf("%.6f\n",ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n,sum,kkk[17],cz[17];

int main()
{
    scanf("%d",&n);

    for(int i=1;i<=n;i++)
	{
		scanf("%d",&kkk[i]);
	}
    for(int i=1;i<=n;i++)
	{
		scanf("%d",&cz[i]);
	}

    for(int i=1;i<=720720;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		if(i%kkk[j]==cz[j])
			{
				sum++;
				break;
			}
		}

	}

    double ans=sum/1.0/720720;
    printf("%.6lf",ans);
    return 0;
}

#include <iostream>
using namespace std;

int m[16],r[16],n;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> m[i];
	for(int i = 0; i < n; i++)
		cin >> r[i];
	double res = 0;
	int t = 0;
	int x = 65536;
	for(int i = 0; i < x; i++) {

		for(int j = 0; j < n; j++) {
			if(i % m[j] == r[j]) {
				t++;
				break;
			}
		}
	}
	printf("%.5lf",(double) t / x);

	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int R[20];
int M[20];
int n;
bool check(int day){
	bool rat=false;
	for(int i=0;i<n;i++){
		rat=rat|(day%M[i]==R[i]);
	}
	return rat;
}
int main(){

	scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d",&M[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	int a,b;
	a=b=0;
	for(int i=0;i<10000000;i++){
		if(check(i)){
			a++;
		}
		else{
			b++;
		}

	}
	printf("%0.8f\n",(a+0.0)/(a+b));
	return 0;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>

int r[20],m[20];

int main() {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&m[i]);
    for(int i=0; i<n; i++)
        scanf("%d",&r[i]);
    int sum = 0;
    for(int i=0; i<10000000; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i%m[j] == r[j])
            {
                sum++;
                break;
            }
        }
    }
    printf("%.8lf\n",1.0*sum/(1.0*10000000));

}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1010000000
#define eps 1e-8

int n,m[11111],r[11111];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>m[i];
    for(int i=0;i<n;i++)
        cin>>r[i];

    int cnt=0;
    double all=0;

    for(int i=1;i<=5000000;i++){
        bool flag=true;
        for(int j=0;j<n;j++)
        if(i%m[j]==r[j])
            flag=false;

        if(flag==false)
            cnt++;
        all=all+1;
    }
    printf("%.5f",cnt/all);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(int argc, const char **argv) {
    if (argc==2) {
        freopen(argv[1], "r", stdin);
    }
    int a = 1;
    int n;
    cin>>n;
    int m[20],d[20];
    for(int i=0 ; i< n ; i++) {
        cin>>m[i];

    }
    for(int i=0 ; i< n ; i++) {
        cin>>d[i];
    }
    int ans =0;
    for(int i=0 ; i< 1e6 ; i++) {
        for(int j=0 ; j< n ; j++) {
            if (i%m[j]==d[j]) {
                //cerr<<i<<" "<<j<<" "<<endl;
                ans++;
                break;
            }
        }
    }

    cerr<<ans<<" "<<a<<" "<<endl;
    cout<<fixed<<setprecision(10)<<(double)ans/(double)1e6<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];  //两个数组
int main()
{
    double n,sum=0;  //n项,sum是总和(记得清零)
    cin>>n;  //读入
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<1000000;i++)  //枚举
        for(int j=0;j<n;j++)
            if(i%a[j]==b[j])  //判断
            {
                sum++;  //累加
                break;  //防止重复计算
            }
    cout<<setprecision(6)<<fixed<<sum/1000000;//输出
}

#include<bits/stdc++.h>
using namespace std;
int m[17],r[17];
int n,sum;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d",&m[i]);
	for(int i=1;i<=n;i++)
	  scanf("%d",&r[i]);
	for(int i=1;i<=1000000;i++)
	  for(int j=1;j<=n;j++)
	    if(i%m[j]==r[j]){
	      sum++;
		  break;
	    }
	printf("%.6f\n",(float)sum/1000000);
}

#include<bits/stdc++.h>
#define N 20
using namespace std;
int a[N],b[N];
int main(){
    double n,egg=0;
    scanf("%lf",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)scanf("%d",&b[i]);
    for(int i=0;i<1e7;i++)
        for(int j=0;j<n;j++)
            if(b[j]==i%a[j]){
                egg++;
                break;
            }
    printf("%.6lf\n",egg/1e7);
    return 0;
}

#include<cstdio>
#pragma gcc optimize(3)
int n,tot=1,ans,d,m[20],r[20];
inline int gcd(int a,int b)
{
	if(!b)
		return a;
	return gcd(b,a%b);
}
inline int read()
{
    int k=0;
    char tmp=getchar();
    while('0'>tmp||'9'<tmp)
        tmp=getchar();
    while('0'<=tmp&&'9'>=tmp)
    {
        k=10*k+tmp-'0';
        tmp=getchar();
    }
    return k;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		m[i]=read(),tot=m[i]*tot/gcd(tot,m[i]);
	for(int i=1;i<=n;++i)
		r[i]=read();
	for(int i=1;i<=tot;++i)
		for(int j=1;j<=n;++j)
			if(i%m[j]==r[j])
			{
				++ans;
				break;
			}
	return 0&printf("%.6lf",(double)ans/(double)tot);
}

#include<bits/stdc++.h>
using namespace std;
int n,sum,i,j,m[1000005],r[1000005];
double ans;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
		cin>>m[i];
    for(i=1;i<=n;i++)
		cin>>r[i];
    for(i=1;i<=720720;i++)
       for(j=1;j<=n;j++)
           if(i%m[j]==r[j]){
		   	   sum++;break;
		   }
    ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

// wxw akioi
#include<bits/stdc++.h>

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}
int m[20];
int r[20];

int main(){
    int n = inp();
    for(int i = 1; i <= n; i++)
        m[i] = inp();
    for(int i = 1; i <= n; i++)
        r[i] = inp();
    int ans = 0;
    for(int i = 0; i <= 5000000; i++){
        bool flg = false;
        for(int j = 1; j <= n; j++)
            if(i % m[j] == r[j]){
                flg = true;
                break;
            }
        if(flg)
            ans++;
    }
    // printf("%d\n", ans);
    printf("%.10lf", (double)ans / 5000000.00);
}

#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;
ll n,a[20],b[20],ans;
void in()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
}
void work()
{
for(int i=0;i<=1000000;i++)
for(int j=1;j<=n;j++)
if(i%a[j]==b[j]){ans++;break;}
}
void out()
{
cout<<ans/1000000.0;
}
int main()
{
  in();
  work();
  out();
  return 0;
}

#include <iostream>
#include <vector>

unsigned long long gcd(unsigned long long a, unsigned long long b) {
	return b == 0 ? a : gcd(b, a%b);
}

unsigned long long lcm(unsigned long long a, unsigned long b) {
	return a*b / gcd(a, b);
}

int main() {
	unsigned int n;
	std::cin >> n;
	std::vector<unsigned int> m(n), r(n);
	unsigned long long l = 1;
	for (unsigned int i = 0; i < n; ++i) {
		std::cin >> m[i];
		l = lcm(l, m[i]);
	}
	for (unsigned int i = 0; i < n; ++i) {
		std::cin >> r[i];
	}
	long double t = 0;
	for (unsigned int d = 0; d < l; ++d) {
		for (unsigned int i = 0; i < n; ++i) {
			if (d%m[i] == r[i]) {
				++t;
				break;
			}
		}
	}
	t /= l;
	std::cout << t;
}

#include<cstdio>
int n,tot=1,ans,d,m[20],r[20];
double out;
int gcd(int a,int b)
{
	if(!b)
		return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		tot=m[i]*tot/gcd(tot,m[i]);
	}
	for(int i=1;i<=n;++i)
		scanf("%d",&r[i]);
	for(int i=1;i<=tot;++i)
		for(int j=1;j<=n;++j)
			if(i%m[j]==r[j])
			{
				++ans;
				break;
			}
	printf("%.6lf",(double)ans/(double)tot);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
int main()
{
    double n,sum = 0;
    cin >> n;
    for(int i = 0;i < n;++i)cin >> a[i];
    for(int i = 0;i < n;++i)cin >> b[i];
    for(int i = 0;i < 1000000;++i)
        for(int j = 0;j < n;++j)
            if(i % a[j] == b[j])
            {
                ++sum;
                break;
            }
    cout << setprecision(6) << fixed << sum / 1000000;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,sum,m[17],r[17];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>m[i];
	}
    for(int i=1;i<=n;i++){
    	cin>>r[i];
	}
    for(int i=1;i<=720720;i++){
    	for(int j=1;j<=n;j++){
       		if(i%m[j]==r[j]){
			   sum++;
			   break;
			}
	   	}
	}
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<bits/stdc++.h>//又忍不住了~~
using namespace std;
int n,a[100],b[100],num,i,j;
double aa;
int main()
{
    cin>>n;
	for(i=1;i<=n;i++){
	cin>>a[i];
    }
	for(i=1;i<=n;i++){
	cin>>b[i];
 }
    for(i=1;i<=100000;i++){
    	for(j=1;j<=n;j++){
    		if(i%a[j]==b[j]){
    			num++;
    			break;
			}
		}
	}
	aa=1.0*num/100000;
	cout<<setprecision(6)<<fixed<<(aa);//借鉴
	return 0;
    }

#include<bits/stdc++.h>
using namespace std;
int n, sum, a[17], b[17];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
    for(int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}
    for(int i = 1; i <= 720720; i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		if(i % a[j] == b[j])
			{
				sum++;
				break;
			}
		}
	}
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <deque>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <stdint.h>
using namespace std;

#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair

#define ftn(i, n) for (int i = 0; i < n; ++i)
#define bte(a) (a).begin(), (a).end()
#define rbte(a) (a).rbegin(), (a).rend()

inline int in() { int x; scanf("%d", &x); return x; }

template<typename T> istream & operator >> (istream &in, vector<T> &vec)
{
	for(int i=0; i<vec.size();++i)
		in >> vec[i];
	return in;
}
template<typename T> ostream & operator << (ostream &out, const vector<T> &vec)
{
	for(int i=0; i<vec.size();++i)
		out << vec[i] << " ";
	return out;
}

#define name "sawmill"
const int INF=1e-6;
vector<vector<int> >f;
vector<int> color;
ll eds=0;
vector<bool> check;

int main()
{
	//freopen(name ".in", "r", stdin); freopen(name ".out", "w", stdout);
	//ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(4);
    int n;
    cin>>n;
    vector<int> arr1(n),arr2(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    cin>>arr2;
    int k=0;
    ld r;
    for(int i=1;i<=100000;i++)
    {
       for(int c=0;c<n;c++)
           if(i%arr1[c]==arr2[c])
           {
               k++;
               break;
           }
    }
    r=ld(k)/ld(100000);
    cout<<r;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MM=1000100;
int n,cnt;
int a[20],b[20];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=MM;i++){
		for(int j=1;j<=n;j++)
			if(i%a[j]==b[j]){
				cnt++;
				break;
			}
	}
	double tmp=(double)cnt/MM;
	printf("%.6lf",tmp);
	return 0;
}

//zdj
#include<cstdio>
#define N 26
int n,a[N],b[N];
signed main()
{
	scanf("%d",&n);int ans(0);
	for(register int i(1);i<=n;i++)
		scanf("%d",&a[i]);
	for(register int i(1);i<=n;i++)
		scanf("%d",&b[i]);
	for(register int i(1);i<720721;i++)
		for(register int j(1);j<=n;j++)
			if(i%a[j]==b[j]){++ans;break;}
	return printf("%.6lf\n",ans/720720.0),0;
}

#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>
#include <iomanip>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#include<math.h>
#include <time.h>
using namespace std;
//set<int>::iterator it;
#define mdlo 1000000007
#define maxERR 0.000000002
//#define minVal -10000000000000
#define maxBits 40
#define pi 3.1415926535897932384626433832795
#define INF 999999999999
#define lim 10000007
typedef long long ll;
long long mInv[41];
long long fact[41];
long long factInv[41];
map<string,long>cityId;
typedef vector<long>adjList;
typedef pair<long,long>edge;
vector<edge>criticalEdges;
adjList Graph[2009];
long N;
ll heights[5];
ll segTree[3];
long nums[5005];
long g[5005];
//ll dp[2][5002][5002];
vector<long>primes;
vector<long>badPrimes;
long funcVal[1];
long dfs_num[2009],dfs_low[2009],visited[2009],parent[109],criticalNode[109];
string cities[109];
vector<string>camCities;
long curDfsNum,camera;
set<string>dictionary;
set<string>::iterator it;
pair<set<string>::iterator,bool> ret;
typedef multiset<long> numset;
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    if(a%b==0)
        return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return (a/gcd(a,b))*b;
}
long long getmoduloInv(long long n){
    if(n==1)
        return 1;
    if(mInv[n]>0)
        return mInv[n];
    long long m=(-1*mdlo)/n;
    m+=mdlo;
    m*=getmoduloInv(mdlo%n);
    mInv[n]=(m%mdlo);
    return mInv[n];
}
vector< long> get_primes(unsigned long maxN){

    char *sieve;
    sieve = new char[maxN/8+1];
    // Fill sieve with 1
    long m=(maxN/8)+1;
    for(long long i=0;i<m;i++)
        sieve[i]=255;
    for(unsigned long x = 2; x <= maxN; x++)
        if(sieve[x/8] & (0x01 << (x % 8))){
            primes.push_back(x);
            // Is prime. Mark multiplicates.
            for(unsigned long j = 2*x; j <= maxN; j += x)
                sieve[j/8] &= ~(0x01 << (j % 8));
        }
    delete[] sieve;
    return primes;
}
ll getPow(ll b,ll p){
	if(b<2||p==1)
		return b;
	if(p==0)
		return 1;
	ll val=getPow(b,p/2);
	val*=val;
	val%=mdlo;
	if(p%2==1){
		val*=b;
		val%=mdlo;
	}
	return val;
}
void buildSegTree(long node,long b,long e){
    if(b==e)
        segTree[node]=b;
    else{
        long mid=(b+e)/2;
        buildSegTree(node*2,b,mid);
        buildSegTree(1+node*2,mid+1,e);
        if(heights[segTree[node*2]]<=heights[segTree[1+node*2]])
            segTree[node]=segTree[node*2];
        else
            segTree[node]=segTree[1+node*2];
    }
}
long long getMin(long node,long segBeg,long segEnd,long qBeg,long qEnd){
    if(segEnd<qBeg||segBeg>qEnd)
        return N+1;
    if(segBeg>=qBeg&&segEnd<=qEnd)
        return segTree[node];
    long mid=(segBeg+segEnd)/2;
    long fh=getMin(node*2,segBeg,mid,qBeg,qEnd);
    long sh=getMin(1+node*2,mid+1,segEnd,qBeg,qEnd);
    if(heights[sh]<heights[fh])
        return sh;
    return fh;
}
stack<long>dfsStack;
bool Allconnected;
void tarjanSCC(long node){
    adjList neighbours=Graph[node];
    dfs_num[node]=curDfsNum;
    dfs_low[node]=curDfsNum;
    curDfsNum++;
    visited[node]=1;
    dfsStack.push(node);
    for(long i=0;i<neighbours.size();i++){
        long curNeighbour=neighbours[i];
        if(visited[curNeighbour]==0)
            tarjanSCC(curNeighbour);
        if(visited[curNeighbour]==1&&dfs_low[curNeighbour]<dfs_low[node])
            dfs_low[node]=dfs_low[curNeighbour];
    }
    if(dfs_num[node]==dfs_low[node]){
        if(node!=1){
            Allconnected=false;
            return;
        }

        while(dfsStack.top()!=node){
            long top=dfsStack.top();
            visited[top]=2;
            dfsStack.pop();
        }
    }
}
void dfsCriticalNode(long node,bool root){
    adjList neighBours=Graph[node];
    dfs_num[node]=curDfsNum;
    dfs_low[node]=curDfsNum;
    curDfsNum++;
    visited[node]=1;
    long child=0;
    for(long i=0;i<neighBours.size();i++){
        long neighBour=neighBours[i];
        if(visited[neighBour]==0){
            child++;
            parent[neighBour]=node;
            dfsCriticalNode(neighBour,false);
            if(dfs_low[neighBour]<dfs_low[node])
                dfs_low[node]=dfs_low[neighBour];
            if(dfs_low[neighBour]>=dfs_num[node]&&!root&&criticalNode[node]==0){
                criticalNode[node]=1;
                camera++;
                camCities.push_back(cities[node]);
            }
        }
        else if(neighBour!=parent[node])
            dfs_low[node]=min(dfs_low[node],dfs_num[neighBour]);
    }
    if(root&&child>1){
                criticalNode[node]=1;
                camera++;
                camCities.push_back(cities[node]);
            }
}
void genTestCase(long N){
    long M=N*sqrt((double)N);
    cout<<N<<" "<<M<<endl;
//    for(long i=0;i<)
}
ll M[20],R[20],me[721000];
int main(void){
 // freopen ("E:/inputSmall.txt","r",stdin);
  //freopen ("E:/outputSmall2.txt","w",stdout);
    ll test_cases=0,l,r,seed=1,maxVal;
	//memset(dp,0,sizeof(dp));
	ll curNum;
	ll n;
	ll ans=0;
	string s,s1;
	cin>>n;
	cout << setprecision(15) << fixed;
	memset(me,0,sizeof(me));
	ll curlcm=1;
	for(long i=0;i<n;i++){
        cin>>M[i];
        curlcm=lcm(M[i],curlcm);
	}
	for(long i=0;i<n;i++){
        cin>>R[i];
        while(R[i]<curlcm){
            me[R[i]]=1;
            R[i]+=M[i];
        }
	}
    ll countt=0;
    for(long i=0;i<curlcm;i++){
        if(me[i]==1)
            countt++;
    }
    double a=curlcm,b=countt;
    cout<<b/a;

	//cin>>test_cases;

	double vol,temp;
//	get_primes(32000);
    for(long T=0;T<test_cases;T++){
      //  printf("Case #%ld: ",T+1);
        while(cin>>N&&N>0){
            T++;
        }
    }
    return 0;
}
/*ll cumDist1[100005];
ll cumDist2[100005];
vector<ll>distFrom1;
vector<ll>distFrom2;
void initFact(){
    fact[0]=1;
    factInv[0]=1;
    for(ll i=1;i<0;i++){
        factInv[i]=(factInv[i-1]*getmoduloInv(i))%mdlo;
        fact[i]=(fact[i-1]*i)%mdlo;
    }
}
bool isLeapyear(long year){
    if(year%4==0&&(year%100!=0||year%400==0))
        return true;
    return false;
}
ll ds,ms,ys,de,me,ye,dc,mc,yc,day;
void next13th(){
    if(ds<13){
        ds=13;
        return;
    }
    ms++;
    ds=13;
    if(ms>12)
    {
        ms=1;
        ys++;
    }
}
    long months[]={31,28,31,30,31,30,31,31,30,31,30,31};
    long dayBeforeMonth[12];
bool validDate(){
    if(ys>ye)
        return false;
    if(ys<ye)
        return true;
    if(ms>me)
        return false;
    if(ms<me)
        return true;
    if(ds>de)
        return false;
    return true;
}
long getDay(long d,long m,long y){
    long day=((y-1900)*365+(y-1900)/4-(y-1900)/100+(y-1600)/400+dayBeforeMonth[m-1]+d+2)%7;
    if(y%4==0&&m<3){
        if(y%400==0||y%100!=0)
            day=(day+6)%7;
    }
    return day;
}
bool iscurDayFriday(){
    if(getDay(ds,ms,ys)==0)
        return true;
    return false;
}
void dijkstra(long startPoint){
    long m;
    if(startPoint==1)
        m=0;
    else
        m=1;
    distMatrix[m][startPoint]=0;
    priority_queue<edge, vector<edge>,greater <edge>>pq;
    pq.push(edge(0,startPoint));
    while(!pq.empty()){
        edge top=pq.top();
        pq.pop();
        ll d= top.first,u=top.second;
        if(distMatrix[m][u]==d){
            for(long i=0;i<graph[u].size();i++){
                ll v=graph[u][i].second;
                ll ec=graph[u][i].first;
                if(distMatrix[m][v]>distMatrix[m][u]+ec){
                    distMatrix[m][v]=distMatrix[m][u]+ec;
                    pq.push(edge(distMatrix[m][v],v));
                }
            }
        }
    }
}
ll vals[1];
ll dp[1];
ll totalSum[1];
long long mInv[1];
long long fact[1];
long long factInv[1];

//long long pow10[18];
long long getmoduloInv(long long n){
    if(n==1)
        return 1;
    if(mInv[n]>0)
        return mInv[n];
    long long m=(-1*mdlo)/n;
    m+=mdlo;
    m*=getmoduloInv(mdlo%n);
    mInv[n]=(m%mdlo);
    return mInv[n];
}
long long onNthbit(long pos,long val){
    return val|pwr2[pos];
}
bool isNthbitOn(long long pos,long long val){
    return (val&pwr2[pos])>0;
}

seg segTree[5];
long N;
void buildSumSegmentTree(long long b,long long e,long long node){
    if(b==e)
    {
         segTree[node].first=vals[b];
         return;
    }
    long long mid=(b+e)/2;
    buildSumSegmentTree(b,mid,node*2);
    buildSumSegmentTree(mid+1,e,1+(node*2));
    segTree[node].first=segTree[2*node].first+segTree[1+(node*2)].first;
}
long long getSum(long long qStart,long long qEnd,long long sStart,long long sEnd,long long node,prop p){

    long k=sEnd-sStart,n;
    for(long i=0;i<p.size();i++){
        segTree[node].second.push_back(p[i]);
        n=p[i];
        segTree[node].first+=(((n+k)*(n+k+1)*(2*n+2*k+1)-(n*(n-1)*(2*n-1)))/6+((n+k)*(n+k+1)-n*(n-1)))/2;
        }
    if(qEnd<sStart||qStart>sEnd)
    {
        return 0;
    }
    if(sStart>=qStart&&sEnd<=qEnd)
    {
         return segTree[node].first;
    }
    long long sMid=(sStart+sEnd)/2;
    prop l;
    for(long i=0;segTree[node].second.size();i++)
        l.push_back(segTree[node].second[i]+sMid+1-sStart);
    return getSum(qStart,qEnd,sStart,sMid,2*node,segTree[node].second)+getSum(qStart,qEnd,sMid+1,sEnd,1+(2*node),l);
}
long long update(ll node, long long sStart,ll sEnd,long upStart,long upEnd){
    if(upEnd<sStart||upStart>sEnd)
        return 0;
    long k=sEnd-sStart,n=sStart+1-upStart;
    if(upStart<=sStart&&upEnd>=sEnd){
        segTree[node].second.push_back(n);
        segTree[node].first+=(((n+k)*(n+k+1)*(2*n+2*k+1))/6);
        segTree[node].first-=(((n*(n-1)*(2*n-1)))/6);
        segTree[node].first+=(((n+k)*(n+k+1)-n*(n-1)))/2;
        return 0;
    }
    ll sMid=(sStart+sEnd)/2;
    update(node*2,sStart,sMid,upStart,upEnd);
    update(1+(node*2),sMid+1,sEnd,upStart,upEnd);
    segTree[node].first=segTree[2*node].first+segTree[1+(node*2)].first;

    for(long i=0;i<segTree[node].second.size();i++){
        n=segTree[node].second[i];
        segTree[node].first+=(((n+k)*(n+k+1)*(2*n+2*k+1)-(n*(n-1)*(2*n-1)))/6+((n+k)*(n+k+1)-n*(n-1)))/2;
    }
    return segTree[node].first;
}
void update(long x,long y){
    long len=y-x+1,add=0;
    for(long i=0;i<len;i++){
        add+=(i+1)*2;
        update(1,0,N-1,x+i,add+vals[x+i]);
    }
}
long getlen(long long num){
    long len=0;
    while(num>0){
        num/=10;
        len++;
    }
    return len;
}
encryptedLine lineConverter(string s){
    encryptedLine el;
    ll val=0,len=s.size();
    for(long i=0;i<len;i++){
        if(s[i]==' '){
            el.push_back(val);
            val=0;
        }
        else{
            val*=26;
            val+=(s[i]-'a');
        }
    }
    el.push_back(val);
    return el;
}
long getPalinDrome(long num){
    long a=num%10;
    long b=(num/10)%10;
    long c=(num/100)%10;
    return num*1000+a*100+b*10+c;
}

vector<unsigned long> get_primes(unsigned long max){
    vector<unsigned long> primes;
    char *sieve;
    sieve = new char[max/8+1];
    // Fill sieve with 1
    long m=(max/8)+1;
    for(long long i=0;i<m;i++)
        sieve[i]=255;
    for(unsigned long x = 2; x <= max; x++)
        if(sieve[x/8] & (0x01 << (x % 8))){
            primes.push_back(x);
            // Is prime. Mark multiplicates.
            for(unsigned long j = 2*x; j <= max; j += x)
                sieve[j/8] &= ~(0x01 << (j % 8));
        }
    delete[] sieve;
    return primes;
}string add(string a,string b){
    int l1=a.size();
    int l2=b.size();
    while(l1<l2){
        a="0"+a;
        l1++;
    }
    while(l2<l1){
        b="0"+b;
        l2++;
    }
    string s;
    int carry=0;
    for(long i=l2-1;i>-1;i--){
        int d=a[i]+b[i]+carry-2*'0';
        carry=d/10;
        a[i]='0'+(d%10);
    }
    if(carry)
        a="1"+a;
    return a;
}
long long mInv[1010];
long long fact[1000];
long long factInv[1000];
long long getmoduloInv(long long n){
    if(n==1)
        return 1;
    if(mInv[n]>0)
        return mInv[n];
    long long m=(-1*mdlo)/n;
    m+=mdlo;
    m*=getmoduloInv(mdlo%n);
    mInv[n]=(m%mdlo);
    return mInv[n];

}

long dp[200010];
vector<weightedPos>points;
vector<weightedPos>modifiedPositions;
vector<long long>heights;
long long segTree[530010];
long N,X,W;
void buildSegTree(long node,long b,long e){
    if(b==e)
        segTree[node]=b;
    else{
        long mid=(b+e)/2;
        buildSegTree(node*2,b,mid);
        buildSegTree(1+node*2,mid+1,e);
        if(heights[segTree[node*2]]<=heights[segTree[1+node*2]])
            segTree[node]=segTree[node*2];
        else
            segTree[node]=segTree[1+node*2];
    }
}
long long getMin(long node,long segBeg,long segEnd,long qBeg,long qEnd){
    if(segEnd<qBeg||segBeg>qEnd)
        return N;
    if(segBeg>=qBeg&&segEnd<=qEnd)
        return segTree[node];
    long mid=(segBeg+segEnd)/2;
    long fh=getMin(node*2,segBeg,mid,qBeg,qEnd);
    long sh=getMin(1+node*2,mid+1,segEnd,qBeg,qEnd);
    if(heights[sh]<heights[fh])
        return sh;
    return fh;
}
long long getMinPos(long node,long segBeg,long segEnd,long qBeg,long qEnd){
    if(segEnd<qBeg||segBeg<qEnd)
        return 0;
    if(segBeg>=qBeg&&segEnd<=qEnd)
        return segTree[node];
    long mid=(segBeg+segEnd)/2;
    long fh=getMin(node*2,segBeg,mid,qBeg,qEnd);
    long sh=getMin(node*2,mid+1,segEnd,qBeg,qEnd);
    return min(fh,sh);
}
long getPos(long val){
    long low=0,high=modifiedPositions.size()-1;
    long mid=(low+high)/2;
    while(low<high){
        if(modifiedPositions[mid].first<val)
            low=mid+1;
        else
            high=mid-1;
        mid=(low+high)/2;
    }
    if(mid>0)
        mid--;
    while(mid<modifiedPositions.size()&&modifiedPositions[mid].first<val)
        mid++;
    return mid;
}
long getMaxGroup(long index){
    if(dp[index]>-1)
        return dp[index];
    long pos=getPos(points[index].first+points[index].second);
    if(pos>=N)
        return 1;
    long nextPoint=getMin(1,0,N-1,pos,N-1);
    dp[index]=1+getMaxGroup(nextPoint);
    return dp[index];
}
*/

// rc.cpp : Defines the entry point for the console application.
//

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>

using namespace std;

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long long uint64;
typedef long long sint64;

uint m[16],
r[16];

bool v[1000000];

int main(int argc, char* argv[])
{
    uint n;
    cin >> n;

    for (uint i = 0; i < n; ++i)
        cin >> m[i];

    for (uint i = 0; i < n; ++i)
        cin >> r[i];

    for (uint i = 0; i < n; ++i)
    {
        for (uint j = r[i]; j < 1000000; j += m[i])
            v[j] = true;
    }

    uint q = 0;
    for (uint i = 0; i < 1000000; ++i)
    {
        if (v[i])
            ++q;
    }

    printf("%.5f\n", (double)q / 1000000.);
    return 0;
}

#pragma comment(linker, "/STACK:134217728")
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <complex>
#include <functional>
#include <cmath>
#include <time.h>

using namespace std;

typedef long long LL;

int n;

int M[16], R[16];

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> M[i];
	for (int i = 0; i < n; ++i)
		cin >> R[i];
	int total = 0;
	for (int i = 0; i < (int)1e6; ++i)
	{
		bool ok = 0;
		for (int j = 0; j < n; ++j)
			ok |= i % M[j] == R[j];
		if (ok)
			total++;
	}

	printf("%.10lf\n", total / 1e6);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ll unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
ll mark[720720];
pii a[16];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    ll i,j,k,n,m=1,c=0;

    cin>>n;

    fr(i,0,n-1)
    scanf("%d",&a[i].first);

    fr(i,0,n-1)
    scanf("%d",&a[i].second);
    //sort(a,a+n);
   // cout<<gc<<" "<<lcm<<endl;

    fr(i,0,n-1)
    {
        if(a[i].first==0)
            continue;

        fr(j,0,720719)
        if(j%a[i].first==a[i].second && mark[j]==0)
            c++ ,mark[j]=1;
    }

    double ans=(double)c/720720;
    // cout<<c<<" "<<setprecision(6)<<ans<<endl;

    printf("%lf\n",ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
double ans=0;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=720720;i++)
		for(int k=1;k<=n;k++)
		{
			if(i%a[k]==b[k]) {++ans;break;}
		}
	ans=ans*1.0/720720;
	printf("%0.6f",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ll unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
bool mark[720720];
pii a[16];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    ll i,j,k,n,m=1,c=0;

    cin>>n;

    fr(i,0,n-1)
    scanf("%d",&a[i].first);

    fr(i,0,n-1)
    scanf("%d",&a[i].second);
    //sort(a,a+n);
   // cout<<gc<<" "<<lcm<<endl;

    fr(i,0,n-1)
    {
        if(a[i].first==0)
            continue;

        for(j=a[i].second;j<720720;j+=a[i].first)
        if(j%a[i].first==a[i].second )
            mark[j]=1;
    }

    c=accumulate(mark,mark+720720,0);

    double ans=(double)c/720720;
    // cout<<c<<" "<<setprecision(6)<<ans<<endl;

    printf("%lf\n",ans);

    return 0;
}

#include<bits/stdc++.h>
#define Max 1000000
using namespace std;
int n;
int a[20];
int b[20];
int ans;
int read()
{
	int s=0;
	char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
	{
		s=(s<<1)+(s<<3)+c-'0';
		c=getchar();
	}
	return s;
}
int main()
{
	int i,j;
	n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	for(i=1;i<=n;i++)
		b[i]=read();
	for(j=0;j<Max;j++)
		for(i=1;i<=n;i++)
			if(j%a[i]==b[i])
			{
				ans++;
				break;
			}
	printf("%lf",ans/1000000.0);
	return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

#ifndef LOCAL
#define cerr if(0)cerr
#endif // LOCAL

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = int(1e9);
const long long INFll = 1ll * INF * INF;
const long double ldINF = 1e+018;
const long double EPS = 0.000000001;
const int base = INF;

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int N = 1000000;
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i == 0)
            mx = a[i];
        else
            mx = mx / __gcd(mx, a[i]) * a[i];
    }
    //cout << mx << endl;
    for (int i = 0; i < n; i++)
        cin >> b[i];
    vector <int> x(1000000);
    for (int i = 0; i < n; i++) {
        int cur = b[i];
        while (cur <= mx)
            x[cur] = 1, cur += a[i];
    }
    int cnt = 0;
    for (int i = 1; i <= mx; i++)
        cnt += x[i];
    ld ans = 1.0 * cnt / mx;
    cout << fixed << setprecision(7) << ans << endl;
    return 0;
 }

#include<cstdio>
#include<string>
using namespace std;

int n,a[20],b[20],ans;

inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar())
	if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar())
	x = x * 10 + ch - '0';
	return x * f;
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	a[i]=read();
	for (int i=1;i<=n;i++)
	b[i]=read();
	for (int i=0;i<1000000;i++)
	for (int j=1;j<=n;j++)
	if (i%a[j]==b[j])
	{
		ans++;
		break;
	}
	printf("%.6lf",(double)1.0*ans/1000000);
	return 0;
}

#include <iostream>

int main()
{
    int N, M[16], R[16], count = 0;
    float percent;

    std::cin >> N;

    for (int i = 0; i < N; i++)
        std::cin >> M[i];

    for (int i = 0; i < N; i++)
        std::cin >> R[i];

    for (int i = 0; i < 9999999; i++)
    {
        for (int j = 0; j < N; j++)
          {
              if(i % M[j] == R[j])
                {count++; break;}
          }
    }
    std::cout << float(count)/(float)(9999999);
    return 0;
}

//ORZ ZWH
#include<iostream>
#include<cstdio>
using namespace std;
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int n;
int a[30],b[30];
int c=0;
int main(){
	n=read();
	for(int i=1;i<=n;i++)  a[i]=read();
	for(int i=1;i<=n;i++)  b[i]=read();
	for(int i=1;i<=1e6;i++)
		for(int j=1;j<=n;j++)
			if(i%a[j]==b[j]){
				c++;break;
			}
	printf("%.6f\n",(c*1.0)/1e6);
	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int n,m[17],r[17],s=1,k;
bool b[720725];

int gcd(int x,int y)
{
    if(!y) return x;
    return gcd(y,x%y);
}

int main()
{
    //freopen("in","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&m[i]);
        s=s*m[i]/gcd(s,m[i]);
    }
	for(int i=1;i<=n;i++)
		scanf("%d",&r[i]);
    for(int i=1;i<=n;i++)
        for(int j=r[i];j<=s;j+=m[i])
            b[j]=1;
    for(int i=0;i<s;i++)
        k+=b[i];
    printf("%.6f",(k*1.0)/s);
    return 0;
}

// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
int main(){
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=720720;i++){
       for(int j=1;j<=n;j++){
           if(i%a[j]==b[j]){
               sum++;
               break;
            }
        }
    }
    double ans;
    ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int a[160],b[160];
int main()
{
    bool flag=0;
    double n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>b[i];
    for(int i=0;i<999999;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i%a[j]==b[j])
            {
                sum=sum+1;
                flag=1;
                break;
            }
        }
    }
    cout<<setprecision(6)<<fixed<<sum/1000000<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n,mx=1000000; cin>>n;
   int m[n],r[n];
   for(int i=0;i<n;i++)
   {
       cin>>m[i];
   }
   for(int i=0;i<n;i++)
   {
       cin>>r[i];
   }
   double ans=0;
   for(int i=0;i<mx;i++)
   {
       for(int j=0;j<n;j++)
       {
           if(i % m[j]==r[j])
           {
               ans++;
               break;
           }
       }
   }
   cout<<fixed<<setprecision(10)<<ans/(mx);
    return 0;
}

#include<stdio.h>

long long int Day[1000000],m[20],r[20];
long long nzd(long long a, long long b)
{
     if(b==0) return a;
     return nzd(b,a%b);
}
int main()
{
long long int n,d=1,c=0,j,i;
double k=0;
scanf("%lld",&n);
for(i=0;i<n;i++)
scanf("%lld",&m[i]);
for(i=0;i<n;i++)
scanf("%lld",&r[i]);
for(i=0;i<n;i++)
{
d=(d*m[i])/nzd(d,m[i]);
}
for(i=0;i<d;i++)
{
for(j=0;j<n;j++){if(i%m[j]==r[j]){c++;break;}}
}
k=(double)c/(double)(d);
printf("%lf",k);
return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int M[17], R[17];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> M[i];
        //cout << "M[" << i << "] = " << M[i] << endl;
        //to = max(to, M[i]);
    }

    for(int i = 0; i < n; ++i)
    {
        cin >> R[i];
    }
    double me = 0, all = 0;
    //cout << "to = " << to << endl;
    for(int j = 0; j < 10000001; ++j)
    {
        for(int p = 0; p < n; ++p)
        {
            if (j % M[p] == R[p])
            {
                me++;
                break;
            }
        }
        all++;
    }
    //cout << "me = " << me << endl;
    //cout << "all = " << all << endl;
    double yes = me/all;
    //cout << "yes = " << yes << endl;
    cout <<fixed << yes << setprecision(8);
    return 0;
}

#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int m[n+1],r[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>m[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>r[i];
	}
	double ans=0;
	for(int i=0;i<1000000;i++)
	 for(int j=1;j<=n;j++)
	  if(i%m[j]==r[j])
	  {
	  	ans++;
	  	break;
	  }
	cout<<ans/1000000<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int MOD = 1e9 + 7; ll INF = 1e18;

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int n, m[16], r[16];

int solve(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> m[i];
	for(int i=0;i<n;i++) cin >> r[i];
	int N = 1;
	for(int i=0;i<n;i++) N = lcm(N, m[i]);
	int ok = 0;
	for(int x=0;x<N;x++){
		int kk = 0;
		for(int i=0;i<n;i++) for(int i=0;i<n;i++){
			if(x % m[i] == r[i])
				kk = 1;
		}
		ok += kk;
	}
	cout << fixed << setprecision(6) << 1.0 * ok / N << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

int lcm(int a, int b)
{
    return (a*b)/gcd(a, b);
}

int main(){
    pair <int,int> arr[17];
    int n;
    int ans;
    int lcm_val;
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i].first;
    }
    for(int i=0;i<n;i++){
        cin>>arr[i].second;
    }
    sort(arr,arr+n);
    lcm_val=arr[0].first;
    for(int i=1;i<n;i++){
        lcm_val=lcm(lcm_val,arr[i].first);
    }
    //cout<<lcm_val<<"\n";

    //cout<<max_value;
    for(int i=1;i<=lcm_val;i++){
        //cout<<i<<"\n";
        for(int j=0;j<n;j++){
            if(i%arr[j].first==arr[j].second){
                count++;
                //cout<<count<<" , when i = "<<i<<" , j = "<<j<<" , arr[j].second = "<<arr[j].second<<"\n";
                break;
            }
        }
    }
    cout<<fixed<<setprecision(6)<<float(count)/float(lcm_val);
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define FORE(ii,aa,bb) for(int ii=aa;ii<bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)
#define type(x) __typeof(x.begin())

#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define y1 fkfrgff
#define ll long long
#define pii pair<int,int>
#define mod 1000000007
#define N (int)(2e5+10)
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endll puts("")
#define endl '\n'
#define inf mod
#define ort ((sol+sag)/2)
int n,r[N],m[N],s;
int main(){
	cin >> n;
	FOR(i,1,n)
		scanf("%d",&r[i]);
	FOR(i,1,n)
		scanf("%d",&m[i]);
	FOR(i,1,1000000){
		FOR(j,1,n){
			if(i % r[j] == m[j]){
				s++;
				break;
			}
		}
	}
	printf("%.12lf\n", (double) s / 1000000.0);
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
int main()
{
    double n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
      for(int i=0;i<n;i++)cin>>b[i];
        for(int i=0;i<1000000;i++)
          for(int j=0;j<n;j++)
            if(i%a[j]==b[j])
            {
                sum++;
                break;
            }
    cout<<setprecision(6)<<fixed<<sum/1000000;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

static const ll MOD = 1000*1000*1000 + 7;
static const double PI = acos(-1.0);

int solve_A()
{
    return 0;
}
int solve_B()
{

}
int solve_C()
{

}

int gcd(int x, int y){
    int m;
    while(y != 0)
    {
        m = x % y;
        x = y;
        y = m;
    }
    return x;
}

int lcd(int x, int y)
{
    int d = gcd(x,y);
    return d == 0 ? 0 : (x/d)* y;
}

int solve()
{
    int n;
    int M[16], R[16];
    cin >> n;
    for(int i= 0; i<n;++i)cin >> M[i];
    for(int i = 0; i< n; ++i) cin >> R[i];

    int l = 1;
    for(int i = 0; i< n; ++i)
        l = lcd(l,M[i]);

    int s = 0;
    for(int i = 0; i <  l; ++i)
    {
        bool c = false;
        for(int j= 0; j < n; ++j)
            c = c || (i % M[j] == R[j]);
        s += c;
    }

    printf("%.4f\n",s/(double)l);

    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define p 1000000007
#define pb push_back
#define mp make_pair
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
Int R[17],M[17];
Int D[17][17],curr=1;
int main()
{
    Int N,ans=0,cnt;
    cin>>N;
    for (Int i=0;i<N;++i)
        cin>>M[i];
    for (Int i=0;i<N;++i)
        cin>>R[i];
    for (cnt=0;cnt<1000000;++cnt)
    {
        for (Int i=0;i<N;++i)
        {
            if (cnt%M[i]==R[i])
            {
                ++ans;
                break;
            }
        }
    }
    double res=(double)ans/(double)(cnt+1);
    printf("%lf",res);
    return 0;
}

#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FO(i,a,b) for(int i=a;i<b;i++)
#define FOD(i,a,b) for(int i=a;i>b;i--)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end(); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define debug cout << "YES" << endl

using namespace std;

typedef pair<int,int>II;
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}

const long double PI = 2*acos(0.0);
const long double eps = 1e-15;
//const int infi = 1e9;
const LL Linfi = 1e18;
const LL MOD = 1000000007;
const int c1 = 31;
const int c2 = 37;
#define maxn 1000010
typedef pair<LL,LL> PII;

LL n;
LL r[20], m[20];
LL day[maxn];

LL lcd(LL a, LL b){
    return a*b/gcd(a,b);
}

void solve(){
    cin >> n;
    LL a = 1;
    LL Max = 0;
    FOR(i, 1, n){
        cin >> m[i];
        a = lcd(a, m[i]);
    }
    FOR(i, 1, n){
        cin >> r[i];
    }
    LL N = 0;
    FOR(i, 1, n){
        if(m[i] != 0){
            FOR(j, 0, a/m[i]){
                day[j*m[i] + r[i]] = 1;
            }
        }
    }
    FOR(i, 1, a) if(day[i] == 1) N++;
    double ans = (double)N/a;
    printf("%.6llf", ans);
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("test.in","r",stdin);
//    freopen("test.out","w",stdout);
    #endif

    solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,num,a[17],b[17];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	for (int i=1;i<=720720;i++)
		for (int j=1;j<=n;j++)
		{
			if (i%a[j]==b[j])
			{
				num++;
				break;
			}
		}
	double ans=1.0*num/720720;
	printf("%.6lf",ans);
	return 0;
}
/*
输入样例#1：
1
2
0
输出样例#1：
0.500000
*/
/*
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[17];
    for(int i=1;i<=16;i++) a[i]=i;
    int sum=1,max=16;
    while(sum<16){
        for(int i=1;i<=16;i++){
            a[i]+=((max-a[i])/i)*i;
            if(a[i]==max) sum++;
              else a[i]+=i,max=a[i],sum=1;
        }
    }
    printf("%d",max);
    return 0;
}
*/

#include <cstdio>
int N, M[16], R[16], O;
int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", M + i);
	for (int i = 0; i < N; i++)
		scanf("%d", R + i);
	for (int i = 0; i < 720720; i++)
	{
		bool o = false;
		for (int j = 0; j < N; j++)
			if (i % M[j] == R[j])
				o = true;
		if (o)
			O++;
	}
	printf("%.10lf\n", O / 720720.0);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cstring>
#include<functional>
#include<iomanip>
using namespace std;
int n, M[20], R[20], liczek;
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> M[i];
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> R[i];
	}
	for(int D = 0; D < 100000; D++)
	{
		for(int i = 1; i <= n; i++)
		{
			if(D % M[i] == R[i])
			{
				liczek++;
				break;
			}
		}
	}
	long double wynik = (long double)liczek / (long double)(100000);
	cout << fixed << setprecision(6) << wynik << endl;

	return 0;
}

/* -*- coding: utf-8 -*-
 *
 * 0656B.cc: B. Scrambled
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 16;

/* typedef */

/* global variables */

int ms[MAX_N], rs[MAX_N];

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

template <typename T>
T lcm(T m, T n) {
  return m * n / gcd<T>(m, n);
}

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", ms + i);
  for (int i = 0; i < n; i++) scanf("%d", rs + i);

  int l = 1;
  for (int i = 0; i < n; i++) l = lcm<int>(l, ms[i]);
  //printf("lcm=%d\n", l);

  int c = 0;
  for (int i = 0; i < l; i++) {
    bool ng = true;
    for (int j = 0; ng && j < n; j++)
      ng = (i % ms[j] != rs[j]);
    if (! ng) c++;
  }

  printf("%.6lf\n", (double)c / l);
  return 0;
}

#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define next liuyifan_next
using namespace std;
ll a[105],b[105];
double n,sum;
int main()
{
    scanf("%lf",&n);
    for(reg int i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(reg int i=1;i<=n;i++)scanf("%lld",&b[i]);
    for(reg int i=1;i<=1000000;i++)
    for(reg int j=1;j<=n;j++)
    if(i%a[j]==b[j])
    {
        sum++;
        break;
    }
    printf("%.6lf",sum/1000000.0);
    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int m[17],r[17];
int sum;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>m[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
    }
    for(int i=0;i<1000000;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i%m[j]==r[j])
            {
                sum++;
                break;
            }
        }
    }
    double ans=(double)(sum/1000000.0);
    printf("%.6f",ans);
}

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  int all = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    all = all / __gcd(all, a[i]) * a[i];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  int ret = 0;
  for (int i = 0; i < all; ++i) {
    bool found = false;
    for (int j = 0; j < n; ++j) {
      if (i % a[j] == b[j]) {
        found = true;
        break;
      }
    }
    if (found) ++ret;
  }
  printf("%.10f\n", (double)ret / all);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int m[N], r[N];
int n;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", m+i);
    for(int i = 0; i < n; ++i) scanf("%d", r+i);
    int s = 0;
    for(int i = 0; i < 10000000; ++i)
    for(int j = 0; j < n; ++j)
            if(i % m[j] == r[j]) {
                ++s; break;
            }

    printf("%.6f\n", s * 1.0 / 10000000);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
   T f=1;x=0;char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+c-'0';
   x*=f;
}
int l[20],r[20];
int main(){
	int n;
    read(n);
    for(int i=1;i<=n;i++){
    	read(l[i]);
    }
    for(int i=1;i<=n;i++){
    	read(r[i]);
	}

	int s=0;
    for(int i=1;i<=720720;i++){
    	for(int j=1;j<=n;j++){
    		if(i%l[j]==r[j]){
				s++;
				break;
			}
		}
	}

    printf("%.6lf",1.0*s/720720);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int m[20], r[20];
    for(int i = 0; i < n; i++) cin >> r[i];
    for(int i = 0; i < n; i++) cin >> m[i];

    int you = 0;
    for(int i = 0; i <= 100000; i++) {
            for(int k = 0; k < n; k++)
                if(i % r[k] == m[k]) {
                    you++;
                    break;
                }
    }
    cout << fixed << setprecision(4) << (((double)you) / (double)(100000+1))<< endl;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%I64d",&x)
#define pl(x) printf("%I64d\n",x)
#define sf(x) sort(x.begin(),x.end(),func)
#define s(x) sort(x.begin(),x.end())
#define pb push_back
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define mp make_pair
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = LLONG_MAX;
const ll ninf = LLONG_MIN;
const ld eps = 1e-12;
const ll N = 1000005;
const ll M = 5005;
const ll LOGN = 19;
ll n;
ll r[N];
ll m[N];
ll power(ll a,ll b)
{
    ll x=1,y=a;
    while(b>0)
    {
        if(b%2==1)
        {
            x=(x*y);
            if(x>mod) x%=mod;
        }
        y = (y*y);
        if(y>mod) y%=mod;
        b /= 2;
    }
    return x;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n) cin >> m[i];
    f(i, n) cin >> r[i];
    ld c = 0;
    for(ll d = 1; d <= 10000000; d++)
    {
        f(i, n)
        {
            if(d % m[i] == r[i])
            {
                c = c + 1.0;
                break;
            }
        }
    }
    ld ans = c / 10000000.0;
    cout << fixed << setprecision(11) ;
    cout << ans << "\n";
    return 0;
}

#include <iostream>
using namespace std;

int main() {

    int n;

    std::cin >> n;

    int *m;
    int *r;

    r = new int[n];
    m = new int[n];

    for (int i = 0; i < n; ++i){
        std::cin >> m[i];
    }

    for (int i = 0; i < n; ++i){
        std::cin >> r[i];
    }

    int dishesDone = 0;

    int max = 0;

    for (int i = 0; i < n; ++i){
        if (m[i] > max){
            max = m[i];
        }
    }

    for(int i = 0; i < max * max * max * max; ++i){
        for (int j = 0; j < n; ++j){
            if (i % m[j] == r[j]){
                ++dishesDone;
                break;
            }
        }
    }

    std::cout << (double)dishesDone / ((double)max * max * max * max) << std::endl;

	return 0;
}

/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define Pi acos(-1)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define ll long long int
#define linf 100000000000000000
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
#define MOD 1000000007
#define MAX 100005

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    ll m[n], r[n];
    for(ll i=0; i<n; i++) cin>>m[i];
    for(ll i=0; i<n; i++) cin>>r[i];
    ll total=0, cnt=0;
    for(int i=0; i<10000000; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i%m[j]==r[j])
            {
                total=i;
                cnt++;
                break;
            }
        }
    }
    if(cnt==0) cout<<0<<endl;
    else cout<<fixed<<setprecision(7)<<(cnt*1.0)/total<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define M 10000000
bool a[M];
int r[20], m[20];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &r[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = r[i]; j < M; j += m[i]) {
      a[j] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    ans += a[i];
  }
  printf("%.6f\n", 1.0 * ans / M);
  return 0;
}

#include<cstdio>
using namespace std;
int n,sum,m[20],r[20];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&m[i]);
    for(int i=1;i<=n;i++) scanf("%d",&r[i]);
    for(int i=1;i<=720720;i++)
       for(int j=1;j<=n;j++)
           if(i%m[j]==r[j]){
               sum++;
               break;
           }
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[25],b[25];
int main()
{
    double n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<1000000;i++)
        for(int j=0;j<n;j++)
            if(i%a[j]==b[j])
            {
                sum++;
                break;
            }
    cout<<setprecision(6)<<fixed<<sum/1000000;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int arr1[17];
int arr2[17];
int main(){
double T;
cin>>T;
for(int i=0;i<T;i++){
    cin>>arr1[i];
}
for(int i=0;i<T;i++){
    cin>>arr2[i];
}
double counter=0;
for(int i=0;i<10000000;i++){
    for(int j=0;j<T;j++){
        if(i%arr1[j]==arr2[j]){
            counter++;
            break;
        }
    }
}
cout<<fixed<<setprecision(6)<<counter/10000000<<endl;
return 0;}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,sum,a[1000],b[1000];
int main()
{
	ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)cin>>b[i];
    for(int i=1; i<=720720; i++)
     for(int j=1; j<=n; j++)
        if(i%a[j]==b[j])
		{
			sum++;
			break;
		}
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
const long total_numbers=8*9*5*11*13*7;
bool ar[total_numbers]={false};
int main()
{

 	#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r" , stdin);
    freopen("Output.txt", "w" , stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int M[n],R[n];
    int Max=-1;

    for(int i=0;i<n;i++)
    {
      cin>>M[i];
      // if(M[i]>Max)
      //       Max=M[i];
    }

    for(int i=0;i<n;i++)
      cin>>R[i];

    //  int ar[Max]={0};
     // long total_numbers=8*9*5*11*13*7;

     for(int i=0;i<total_numbers;i++)
     {
            for(int j=0;j<n;j++)
            {
                  if(i%M[j]==R[j])
                        ar[i]=true;
            }
     }
     long Count=0;
     for(bool i:ar)
     {
      if(i)
            {     Count++;
                 // cout<<i<<" ";
            }
     }
    // cout<<endl;
     double a=Count;
     double b=total_numbers;
     //cout<<a<<endl<<b<<endl;
     float percentage=a/b;
     cout<<percentage;
    // long total_numbers=8*9*5*11*13*7;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,ans,mod[23],ran[32];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>mod[i];
    for(int i=1;i<=n;i++)cin>>ran[i];
    for(int i=1;i<=720720;i++)
       for(int j=1;j<=n;j++)
           if(i%mod[j]==ran[j]){ans++;break;}
    double sum=1.0*ans/720720;
    printf("%.6lf",sum);
    return 0;
}
//我艹你妈逼ＵＫＥ™的给劳资吃尼玛币的屎Iｆｕｃｋｙｏｕ你个ＪＢSBＣＦFBI都到你祖宗坟墓门口了还UKEＢ死样的B

#include <iostream>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;
int main()
{
    int n;
    long double res=0;
    cin>>n;
    int m[16];
    int r[16];
    int a[1000000]={0};
    for (int i=0;i<n;i++) cin>>m[i];
    for (int i=0;i<n;i++) cin>>r[i];
    for (int i=0;i<1000000;i++)
    {
        for(int j=0;j<n;j++) if (m[j]>0 && i%m[j]==r[j]) {a[i]=1; break;}
    }
    int ans=0;
    for (int i=0;i<1000000;i++) ans+=a[i];
    long double l = (double)ans/(double)1000000;
    cout.precision(10);
    cout<<l;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i, a, b) for(int i = a; i <= b; i++)
#define fo(i, a, b) for(int i = a; i < b; i++)
#define fod(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int INF = 1e9, N = 100010;
const ll INFL = 1e18;

typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

int n, R[N], M[N];
int lcm;
int res;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n; ff(i, 1, n) cin >> M[i]; ff(i, 1, n) cin >> R[i];
	lcm = 1;
	ff(i, 1, n) lcm = (lcm * M[i] / __gcd(lcm, M[i]));
	fo(i, 0, lcm) {
		ff(j, 1, n) if (i % M[j] == R[j]) { res++; break; }
	}
	cout << setprecision(4) << fixed << (double)res / lcm << endl;
}

#include<bits/stdc++.h>
using namespace std;
int n,tot,m[20],r[20];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&m[i]);
	for(int i=1;i<=n;i++) scanf("%d",&r[i]);
	for(int i=1;i<=720720;i++) {
		for(int j=1;j<=n;j++) {
			if(i%m[j]==r[j]) {
				tot++;
				break;
			}
		}
	}
	double ans=1.0*tot/720720;
	printf("%.6lf",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
double n,ans=0;
int a[20],b[20];
int main()
{

    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<1000000;i++)
        for(int j=0;j<n;j++)
            if(i%a[j]==b[j])
            {
                ans++;
                break;
            }
    cout<<fixed<<setprecision(6)<<ans/1000000;
}

#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

int lcm(int a, int b) {
    int m = a, n = b;
    while(m != n) {
        if (m > n)
            m -= n;
        else
            n -= m;
    }
    return a * b / m;
}

int main() {
    int number, input;
    vector<int> M, R;
    cin >> number;

    cin >> input;
    M.push_back(input);
    int D = input;
    for (int i = 1; i < number; ++i)
    {
        cin >> input;
        M.push_back(input);
        D = lcm(M[i], D);
    }
    for (int i = 0; i < number; ++i)
    {
        cin >> input;
        R.push_back(input);
    }

    int prob = 0;
    for (int i = 0; i < D; i++) {
        bool found = false;
        for (int j = 0; j < number; j ++) {
            if (!found && R[j] == i % M[j]) {
                prob++;
                found = true;
            }
        }
    }

    cout << setprecision(6) << float(prob) / D << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
int main()
{
    ios::sync_with_stdio(false);
    double sum=0,n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<1000000;i++)
        for(int j=0;j<n;j++)
            if(b[j]==i%a[j])
            {
                sum++;
                break;
            }
    cout<<setprecision(6)<<fixed<<sum/1000000;
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;

#define f first
#define s second
#define pb push_back

int n, r[20], m[20], cnt;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> m[i];
  for (int i = 1; i <= n; i++)
    cin >> r[i];
  for (int i = 0; i <= 1000000; i++)
    for (int j = 1; j <= n; j++)
      if (i % m[j] == r[j]) {
        cnt++;
        break;
      }
  cout << fixed << setprecision(10) << (double)(cnt) / 1000000;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int m[17],r[17],sum;
double ans;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>m[i];
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
    }
    for(int i=0;i<1000000;i++){
        for(int j=1;j<=n;j++){
            if(i%m[j]==r[j]){
                sum++;break;
            }
        }
    }
    ans=(double)(sum/1000000.0);
    printf("%.6f",ans);
}

#include <bits/stdc++.h>
using namespace std;

int M[20], R[20];

int main()
{
    int N;
    scanf("%d", &N);

    for(int i=0; i<N; i++)
        scanf("%d", &M[i]);
    for(int i=0; i<N; i++)
        scanf("%d", &R[i]);

    int ans = 0;

    for(int i=0; i<=10000000; i++)
    {
        for(int j=0; j<N; j++)
        {
            if(i%M[j]==R[j])
            {
                ans++;
                break;
            }
        }
    }

    printf("%.6lf\n", ans/10000000.00);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int Max = 720720;
int m[20],r[20];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>m[i];
	for(int i=1;i<=n;i++)
		cin>>r[i];
	for(int i=1;i<=Max;i++)
		for(int j=1;j<=n;j++)
			if(i%m[j]==r[j])
			{
				ans++;
				break;
			}
	printf("%.5lf\n",1.0*ans/Max);
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define N 40
int a[N],b[N];
double n,sum;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];

    for(int i=0;i<n;i++)cin>>b[i];

    for(int i=0;i<1000000;i++)
        for(int j=0;j<n;j++)
            if(i%a[j]==b[j])
            {
                sum++;
                break;
            }
    printf("%.6f",sum/1000000);
}

#include<bits/stdc++.h>
using namespace std;
int a[20],b[20];
int main()
{
	int i,j,k,o,p;
    double n,l=0;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++)cin>>b[i];
    for(i=0;i<1000000;i++)
    {
    	for(j=0;j<n;j++)
        {
            if(i%a[j]==b[j])
            {
                l++;
                break;
            }
		}
	}
    cout<<setprecision(6)<<fixed<<l/1000000;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX 20

int m[MAX];
int r[MAX];
set<int> SET;
const int N = 720720;

int main(){
    int n;
    scanf("%d",&n);

    for(int i=0;i<n;i++) scanf("%d",&m[i]);
    for(int i=0;i<n;i++) scanf("%d",&r[i]);

    for(int i=0;i<N;i++)
        for(int j=0;j<n;j++)
            if( i % m[j] == r[j]) SET.insert(i);

    printf("%.10f",SET.size()*1.0/N);
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=16;

int n;
int mod[MAXN],rem[MAXN];

// x*a+y*b=g
int egcd(int a,int b,int &x,int &y) {
	if(b==0) { x=1,y=0; return a; }
	int g=egcd(b,a%b,x,y); swap(x,y); y-=x*(a/b); return g;
}
int mymod(int x,int mod) { x%=mod; if(x<0) x+=mod; return x; }
bool combine(int &n1,int &a1,int n2,int a2) {
	// x=a1 mod n1, x=a2 mod n2
	int m1,m2,g=egcd(n1,n2,m1,m2);
	if(a1%g!=a2%g) return false;
	int n3=n1/g*n2,a3=mymod(a1+m1*(n1/g)*(a2-a1),n3);
	//printf("x=%d (mod %d), x=%d (mod %d) -> x=%d (mod %d)\n",a1,n1,a2,n2,a3,n3);
	n1=n3,a1=a3; return true;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&mod[i]); REP(i,n) scanf("%d",&rem[i]);
	ll den=20922789888000LL,num=0;
	REP(i,1<<n) {
		int cmod=1,crem=0,cnt=0; bool ok=true;
		REP(j,n) if(i&(1<<j)) { ++cnt; if(!combine(cmod,crem,mod[j],rem[j])) ok=false; }
		if(!ok) continue;
		//printf("%2x -> mod %d = %d\n",i,cmod,crem);
		if(cnt%2==0) num+=den/cmod; else num-=den/cmod;
	}
	printf("%.9lf\n",1.0*(den-num)/den);

}

int main() {
	run();
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
    if(a==0) return b;
    if(a>b) return gcd(a%b,b);
    return gcd(b%a,a);
}
int main()
{
    long n,m[17],r[17],i,g=1,p=1,c=0,j;
    cin>>n;
    for(i=0;i<n;++i)
        {cin>>m[i];g=gcd(p,m[i]);p=(p*m[i])/g;}
    for(i=0;i<n;++i)
        cin>>r[i];
    for(i=1;i<=p;++i)
    {
        for(j=0;j<n;++j)
        if(i%m[j]==r[j]) {c++;break;}
    }
    //cout<<c<<p;
    long double an=(long double)c / (long double)p;
    cout<<an;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,sum,m[17],r[17];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&m[i]);
    for(int i=1;i<=n;i++) scanf("%d",&r[i]);
    for(int i=1;i<=720720;i++)
       for(int j=1;j<=n;j++)
           if(i%m[j]==r[j]){sum++;break;}
    double ans=1.0*sum/720720;
    printf("%.6lf",ans);
    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int m[17],r[17];
int sum;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>m[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
    }
    for(int i=0;i<1000000;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i%m[j]==r[j])
            {
                sum++;
                break;
            }
        }
    }
    double ans=(double)(sum/1000000.0);
    printf("%.6f",ans);
}

#include<bits/stdc++.h>
using namespace std;
int m[20],r[20];
int main()
{
    int n;
	scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&m[i]);
    for(int i=1;i<=n;i++) scanf("%d",&r[i]);
    int ans1=1;
    for(int i=0;i<=720720;i++)
    {
    	for(int j=1;j<=n;j++)
    	{
    		if(i%m[j]==r[j])
			{
				ans1++;
				break;
			}
		}
	}
    printf("%.10f\n",ans1/720720.0);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
int mark[39];
pii a[16];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int i,j,k,n,c=0;

    cin>>n;

    fr(i,0,n-1)
     scanf("%d",&a[i].first);

    fr(i,0,n-1)
     scanf("%d",&a[i].second);

    pii mx=mp(0,0);
    fr(i,0,n-1)
     mx=max(mx,a[i]);

    //sort(a,a+n);
 //   cout<<mx.first<<" "<<mx.second<<endl;
    int last=mx.first*2+mx.second;

    fr(i,0,n-1)
     {
         if(a[i].first==0)
            continue;

         fr(j,1,last)
              if(j%a[i].first==a[i].second && mark[j]==0)
                c++ ,mark[j]=1;
     }
   double ans=(double)c/last;
  // cout<<c<<" "<<setprecision(6)<<ans<<endl;

   printf("%lf\n",ans);

    return 0;
}

//      go_on
#include <bits/stdc++.h>
using namespace std;

//      LOOPS AND MEM
#define mz(a) memset(a,0,sizeof(a))
#define md(a,m,n) memset(a,0,sizeof(a[0][0])*m*n);
#define mmin1(a) memset(a,-1,sizeof(a))
#define minf(a) memset(a,MEMSET_INF,sizeof(a));
#define f(i,a,n) for(int i=a;i<=n;++i)
#define fs(i,a,n) for(int i=a;i<n;++i)
#define fl(i,n,a) for(int i=n;i>=a;--i)

//       I/O
#define i(n) cin>>n
#define is(n) scanf("%s",n)
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define o(n) cout<<n
#define p(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define os cout<<" "
#define on cout<<"\n"

//       CONTAINERS
#define ll long long int
typedef vector <ll> vi;
typedef pair<ll, ll> pii;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  a.begin(),a.end()
//#define fv(i,v) for(auto i = v.begin();i !=v.end(); ++i)

//        DEF AND INIT

#define eps 1e-15
#define N 100005
#define M 1000000000
/*map< string, int > m;
map< string, int > :: iterator it;*/

int a[N],x[20],y[20];
int main()
{
    int flag=0,n;
    mz(a);
    i(n);
    f(i,0,n-1)
    {
        i(x[i]);
    }
    f(i,0,n-1)
    {
        i(y[i]);
    }
    f(i,0,n-1)
    {
        if(x[i]==1)
        {
            if(x[i]==0)
            {
                break;
                flag=1;
            }
        }
        else
        {
            int k=0;
            while(((x[i]*k)+y[i])<=100000)
            {
                a[((x[i]*k)+y[i])]++;
                ++k;
            }
        }
    }
    if(flag)
    {
        o("1");
        return 0;
    }
    double cnt=0;
    f(i,0,N)
    {
        if(a[i])    ++cnt;
    }
    o(cnt/(100001));
    return 0;
}

/*
   Mayank Pratap Singh
   MNNIT, 2nd year IT

   AC ho.
*/
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define MOD 1000000007

typedef long long ll;
typedef long double ld;

const int INF=(int)(1e9);
const ll INF64=(ll)(1e18);
const ld EPS=1e-9;
const ld PI=3.1415926535897932384626433832795;

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef vector<list<int> > vl;
typedef map<int,int> mi;
typedef map<string,int> ms;
typedef set<int> si;

ll power(int base,int expo){

    if(expo==0)
    	 return 1;

    ll f=power(base,expo/2);

    if(expo%2==0)
        return f*f;

    else
        return base*f*f;

}

int main(){

  int n;

  scanf("%d",&n);

  int r[20],m[20];

  int tdays=0,wdays=0;

  double ans=0;

  for(int i=0;i<n;++i){
     scanf("%d",&m[i]);

  }

  for(int i=0;i<n;++i){
  	 scanf("%d",&r[i]);

  }

  double prev=0;

  double curr=(1.0-prev)*(1.0/m[0]);

  ans+=curr;

  prev=curr;

  for(int i=1;i<n;++i){

      curr=(1.0-prev)*(1.0/m[i]);

      ans+=curr;

      prev=curr;

  }

  printf("%0.6lf\n",ans);

}

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 1; i <= int(n); i++)
#define lli long long
#define mp make_pair
#define pi pair<int,int>
#define pli pair<lli,lli>
#define pb push_back
#define x first
#define y second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const double EPS = 1e-24;
const lli mod = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
const double PI = 3.14159265359;
int INF = 2147483645;
lli INFINF = 9223372036854775807;

template <class T>T Max2(T a,T b){return a<b?b:a;}
template <class T>T Min2(T a,T b){return a<b?a:b;}
template <class T>T Max3(T a,T b,T c){return Max2(Max2(a,b),c);}
template <class T>T Min3(T a,T b,T c){return Min2(Min2(a,b),c);}
template <class T>T Max4(T a,T b,T c,T d){return Max2(Max2(a,b),Max2(c,d));}
template <class T>T Min4(T a,T b,T c,T d){return Min2(Min2(a,b),Max2(c,d));}

using namespace std;
lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m){lli x=a*b;x%=m;return x;}

pi operator - (pi A,pi B) { return mp(A.x-B.x,A.y-B.y); }
lli operator * (pi A,pi B) { return A.x*B.y-A.y*B.x; }
typedef vector< int > vi;
typedef vector< vi > vvi;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,d=1;
double a;
cin>>n;
int m[n],r[n];
forn(i,n) cin>>m[i];
forn(i,n) cin>>r[i];
forn(i,n){
	if((i%m[i]) == r[i])
		d++;

}
a = (double)d*(1.0000)/(n+1);
cout<<a;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int M[30],R[30];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>M[i];
    for(int i=0;i<n;i++)
        cin>>R[i];
    int a=0,b=0;
    double ans=1e90,ans2=1e89;
    int k=0;
    while(fabs(ans-ans2)>0.00001)
    {
        k++;
        for(int i=0;i<n;i++)
            if(k%M[i]==R[i])
            {
                a++;
                break;
            }
        ans2=ans;
        ans=a;
        ans=ans/(double(k));
    }
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
#define LL long long
#define VI vector<int>
#define Pr pair<int,int>
#define fread() freopen("in.txt","r",stdin)
#define fwrite() freopen("out.txt","w",stdout)

using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
const int msz = 10000;

int m[22],r[22];

int main()
{
    //fread();
    //fwrite();

    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; ++i) scanf("%d",&m[i]);
    for(int i = 0; i < n; ++i) scanf("%d",&r[i]);

    int day = 0;
    int ans = 0;
    int tmp = 1;
    for(int i = 0; i < n; ++i)
    {
        if(!r[i]) tmp = tmp*m[i]/__gcd(tmp,m[i]);
        else tmp = tmp*r[i]/__gcd(tmp,r[i]);
    }

    //printf("%d\n",tmp);
    while(day < tmp)
    {
        day++;
        int f = 0;
        for(int i = 0; i < n; ++i)
        {
            if(day%m[i] != r[i]) continue;
            ++f;
        }
        if(f) ans++;
    }

    printf("%.6f\n",ans*1.0/day);
    return 0;
}

#include<stdio.h>
#include<malloc.h>
void interchange(int arr[][2],int i,int j)
{
    int temp;
    temp=arr[i][0];
    arr[i][0]=arr[j][0];
    arr[j][0]=temp;
    temp=arr[i][1];
    arr[i][1]=arr[j][1];
    arr[j][1]=temp;
}
int partition(int arr[][2],int m,int n)
{
    int i,j,temp;
    i=m;
    j=n-1;
    i=i+1;
    while(i<=j)
    {
    while(arr[i][0]<=arr[m][0]&&i<=j)
    {
        i=i+1;
    }
    while(arr[j][0]>=arr[m][0]&&j>=i)
    {
        j=j-1;
    }
    if(j>i)
    {
        interchange(arr,i,j);
    }
    }
    temp=arr[m][0];
    arr[m][0]=arr[j][0];
    arr[j][0]=temp;
    temp=arr[m][1];
    arr[m][1]=arr[j][1];
    arr[j][1]=temp;
    return j;
}
void iquicksort(int arr[][2],int m,int n)
{
    int stack[n-m][2];
    int top=-1;
    int j;
    while(1)
    {
        if(m<n)
        {
            j=partition(arr,m,n+1);
            top++;
            stack[top][0]=j+1;
            stack[top][1]=n;
            n=j-1;
        }
        else
        {
            if(top!=-1)
            {
                m=stack[top][0];
                n=stack[top][1];
                top--;
            }
            else
            {
                return;
            }
        }
    }
}
int main()
{
    int arr[20][2];
    int n,i;
    //printf("enter n\n");
    scanf("%d",&n);
    //arr=(int *)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
    {
        //printf("enter %d\n",i+1);
        scanf("%d",&arr[i][0]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i][1]);
    }
    iquicksort(arr,0,n-1);
    int track[arr[n-1][0]][2];
    int key[1][2]={0,0};
    int mark,mark1,j;
    for(i=0;i<arr[n-1][0];i++)
    {
        track[i][0]=i+1;
        key[0][0]++;
    }
    for(i=0;i<n;i++)
    {
        mark=i%2;
        mark1=(i+1)%2;
        for(j=0;j<key[0][mark];j++)
        {
            if((track[j][mark])%arr[i][0]!=arr[i][1])
            {
                track[key[0][mark1]][mark1]=track[j][mark];
                key[0][mark1]++;
                //printf("copyof %d from %d to %d",track[key[0][mark]][mark],key[0][mark],key[0][mark1]);
            }
        }
        key[0][mark]=0;
    }
    printf("%f",1-((float)key[0][mark1]/(float)arr[n-1][0]));
    /*for(i=0;i<n;i++)
    {
        printf("%d ",arr[i][0]);
    }
    printf("\n");
    for(i=0;i<n;i++)
    {
        printf("%d ",arr[i][1]);
    }*/
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
int mark[39];
pii a[16];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int i,j,k,n,c=0;

    cin>>n;

    fr(i,0,n-1)
     scanf("%d",&a[i].first);

    fr(i,0,n-1)
     scanf("%d",&a[i].second);

    //sort(a,a+n);

    fr(i,0,n-1)
     {
         if(a[i].first==0)
            continue;

         fr(j,1,30)
              if(j%a[i].first==a[i].second && mark[j]==0)
                c++ ,mark[j]=1;
     }
   double ans=(double)c/30;
   //cout<<c<<" "<<setprecision(6)<<ans<<endl;
   printf("%lf\n",ans);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n, x;
int m[20];
int r[20];
int seged;
double ossz;
double arany;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    ossz=0;
    for (int i=1; i<=n; i++)
    {
        cin>>x;
        if (x==0) x++;
        m[i]=x;
    }
    for (int i=1; i<=n; i++)
    {
        cin>>x;
        if (x==0) x++;
        r[i]=x;
    }
    for (int i=1; i<=720720; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (i%m[j]==i%r[j])
            {
                ossz=ossz+1;
                j=n+1;
            }
        }
    }
    ossz=ossz/720720;
    ossz+=0.0001;
    cout<<setprecision(6)<<ossz;
}

#include <iostream>

int main()
{
    int N, M[16], R[16], count = 0;
    float percent;

    std::cin >> N;

    for (int i = 0; i < N; i++)
        std::cin >> M[i];

    for (int i = 0; i < N; i++)
        std::cin >> R[i];

    for (int i = 0; i < 99999999; i++)
    {
        for (int j = 0; j < N; j++)
          {
              if(i % M[j] == R[j])
                count++;
          }
    }
    percent = float(count)/(float)(99999999);
    std::cout << percent;
    return 0;
}

#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FO(i,a,b) for(int i=a;i<b;i++)
#define FOD(i,a,b) for(int i=a;i>b;i--)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end(); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define debug cout << "YES" << endl

using namespace std;

typedef pair<int,int>II;
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}

const long double PI = 2*acos(0.0);
const long double eps = 1e-15;
//const int infi = 1e9;
const LL Linfi = 1e18;
const LL MOD = 1000000007;
const int c1 = 31;
const int c2 = 37;
#define maxn 100010
typedef pair<LL,LL> PII;

int n;
int r[20], m[20];
int day[maxn];

int lcd(int a, int b){
    return a*b/gcd(a,b);
}

void solve(){
    cin >> n;
    int a = 1;
    int Max = 0;
    FOR(i, 1, n){
        cin >> m[i];
        a = lcd(a, m[i]);
    }
    FOR(i, 1, n){
        cin >> r[i];
    }
    int N = 0;
    FOR(i, 1, n){
        if(m[i] != 0){
            FOR(j, 0, a/m[i]){
                if(day[i*m[i] + r[i]] == 0){
                    N++;
                    day[i*m[i] + r[i]] = 1;
                }
            }
        }
        if(a == m[i]) Max = max(Max, r[i]);
    }
    double ans = (double)N/(a + Max);
    printf("%.6llf", 1-ans);
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("test.in","r",stdin);
//    freopen("test.out","w",stdout);
    #endif

    solve();

    return 0;
}

#include<bits/stdc++.h>

#define MAX_INT 2147483647
#define MIN_INT -2147483648
#define N 100000
#define pb(x) push_back(x)
#define fi first
#define se second

using namespace std;

int m[18], r[18];

int mcd(int a, int b){
	if(a%b==0) return b;
	else return (a/b, a%b);
}

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> m[i];
	for(int i=0; i<n; i++) cin >> r[i];

	int M = 1;
	if(n==1) M = m[0];
	else{
		M = m[0];
		for(int i=1; i<n; i++){
			int aux = M;
			M *= m[i];
			M /= mcd(aux, m[i]);
		}
	}

	int cont = 0;
	for(int i=0; i<M; i++){
		bool ok = true;
		for(int j=0; ok && j<n; j++){
			if(i%m[j]==r[j]) ok = false;
		}
		if(!ok) cont++;
	}

	printf("%.5f\n", (double)cont/M);
	return 0;
}

#include <cstdio>
using namespace std;
int a[25],b[25];
int main()
{
    int i,j;
    double n,sum=0;
    scanf ("%d",&n);
    for(i=0; i<n; i++) scanf ("%d",&a[i]);
    for(i=0; i<n; i++) scanf ("%d",&b[i]);
    for(i=0; i<720720;  i++)
        for(j=0; j<n; j++)
            if(i%a[j]==b[j])
            {
                sum++;
                break;
            }
    double ans=sum*1.0/720720;
    printf("%.6lf\n",ans);
    return 0;
}

#include <iostream>
#include <iomanip>
using namespace std;
int gcd(int x, int y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	if (x < y) {
		return lcm(y, x);
	}
	return x * y / gcd(x, y);
}
int main(void) {
	int n;
	cin >> n;
	int m[16], r[16];
	int max = 1;
	for (int i = 0;i < n;i++) {
		cin >> m[i];
		if (lcm(max, m[i]) > max) {
			max = lcm(max, m[i]);
		}
	}
	for (int i = 0;i < n;i++) {
		cin >> r[i];
	}
	int sum = 0;
	for (int j = 0;j < max;j++) {
		for (int i = 0;i < n;i++) {
			if (j % m[i] == r[i]) {
				sum++;
				break;
			}
		}
		if (sum >= 16) {
			break;
		}
	}
	cout << fixed << setprecision(6) << (double)sum / (double)max;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int a[160],b[160];
int main()
{
    bool flag=0;
    double n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>b[i];
    for(int i=0;i<99999;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i%a[j]==b[j])
            {
                sum=sum+1;
                flag=1;
                break;
            }
        }
    }
    cout<<setprecision(6)<<fixed<<sum/1000000<<endl;
    return 0;
}

#include <bits//stdc++.h>
using namespace std;

int main()
{
    int d[20], r[20];
    int n, cnt1 = 0, mx = 0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>d[i];
        mx = max(d[i], mx);
    }
    for(int i=0; i<n; i++){
        cin>>r[i];
    }
    for(int i=0; i<=10000000; i++){
        for(int j=0; j<n; j++){
            if(i%d[j] == r[j]) {
                cnt1++;
                break;
            }
        }
    }
    printf("%lf\n", (double)cnt1/mx);
}

//Created By Me
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>

using namespace std;

#define INF 2147483647
#define MOD 1000000007
#define pb push_back
#define sc scanf
#define pr printf
#define ex exit(0)
#define fname ""
#define mp make_pair

typedef long long ll;

const int N = 200001, Q = 2001;
int n, M[Q], R[Q], kol, mx;
int main () {

	#ifndef ONLINE_JUDGE

		freopen(fname".in", "r", stdin);
		freopen(fname".out", "w", stdout);

	#endif
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> M[i], mx = max (mx, M[i]);
	for (int i = 1; i <= n; i++)
		cin >> R[i];
	for (int i = 1; i <= mx; i++) {
		for (int j = 1; j <= n; j++)
			if (i % M[j] == R[j]) {
				kol++;
				break;
			}
	}
	pr("%.9lf", double(double(kol) / mx));
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int R[20],M[20],N,maxi,sm;
bool B[20];
double rs = 0;
int main(){
	cin >> N;
	for(int i = 0;i<N;i++) {
		cin >> R[i];
		if(maxi < R[i]) maxi = R[i];
	}

	for(int i = 0;i<N;i++) cin >> M[i];
	for(int i = 1;i<=maxi;i++){
		for(int j = 0;j<N;j++) B[i] = (B[i] || (i%R[j] == M[j]));
		if(B[i]) sm++;
	}
	if(sm == 0) cout << fixed << setprecision(10) << rs;else
	cout << fixed << setprecision(10) << 1.0*sm/maxi;
}

#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-9
#define MX   (lmt+20)
#define inf  2000000000
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  1000000

ll r[MX], m[MX];

int main()
{
    ll n,tot = 0 , cnt = 0;
    cin>>n;
    rep(i,1,n) {cin>>m[i]; tot = max(tot , m[i]);}
    rep(j,1,n) cin>>r[j];

    rep(i,0,tot-1){

        int chk = 0;
        rep(j,1,n){
            if( i % m[j]==r[j] ){
                chk = 1;
            }
        }

        if(chk) cnt++;
    }

    double ans = (double )cnt / (double)tot;

    cout<<setprecision(10)<<fixed<<ans<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m[16],r[16],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&r[i]);
	}
	for(int i=1;i<=720720;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(i%m[j]==r[j])
			{
				sum++;
				break;
			}
		}
	}
	double ans=(double)sum/720720.0;
	printf("%.6lf\n",ans);
	return 0;
}

/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define Pi acos(-1)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define ll long long int
#define linf 100000000000000000
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
#define MOD 1000000007
#define MAX 100005

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    ll m[n], r[n];
    for(ll i=0; i<n; i++) cin>>m[i];
    for(ll i=0; i<n; i++) cin>>r[i];
    ll total=0, cnt=0;
    for(int i=0; i<10000000; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i%m[j]==r[j])
            {
                total=i;
                cnt++;
                break;
            }
        }
    }
    cout<<total<<" "<<cnt<<endl;
    if(cnt==0) cout<<0<<endl;
    else cout<<fixed<<setprecision(7)<<(cnt*1.0)/total<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int r[1000], m[1000];

int main () {
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> r[i];
    for (int i = 1; i <= n; i++)
        cin >> m[i];
    for (int i = 0; i <= n * 10; i++) {
        int num = 0;
        for (int j = 1; j <= n; j++) {
            if (i % r[j] == m[j]) {
                num++;
            }
        }
        if (num == 1)
            ans++;
    }
    printf ("%.6f\n", ans * 1.0 / (n * 10 + 1));
    return 0;
}

#include<iostream>
#include<bits/stdc++.h>

using namespace std;
int flag[100005]={0};
int main()
{
    int i,j,k,n;
    cin>>n;
    int m[n],r[n];
    for(i=0;i<n;i++)cin>>m[i];
    for(i=0;i<n;i++)cin>>r[i];
    int count=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<366;j++)
        {
            if((j%m[i]==r[i])&&flag[j]==0)
            {
                count++;
                flag[j]=1;
            }
        }
    }
    double v=(double)count/366.0;
    printf("%lf\n",v);
    return 0;
}

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
//const int MAX=0x7fffffff;
int min(int a,int b)
{
    if(a<b)return a;
    else return b;
}
int max(int a,int b)
{
    if(a>b)return a;
    else return b;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n;
	scanf("%d",&n);
	int r[20],m[20];
	for(int i=0;i<n;i++)
		scanf("%d",&m[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&r[i]);
	int cnt=0;
	for(int i=0;i<=n;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
		{
			if(i%m[j]==r[j])
				sum++;
		}
		if(sum==1)
			cnt++;
	}
	double x=(double)cnt/(n+1);
	printf("%.6lf\n",x);
    return 0;
}

#include<iostream>
#include<iomanip>
using namespace std;
int m[20],r[20];
int main()
{
    int n;
	double sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
	{
	cin>>m[i];
	}
    for(int i=0;i<n;i++)
	{
	cin>>r[i];
	}
    for(int i=0;i<1000000;i++)
	{
        for(int j=0;j<n;j++)
        {
            if(i%m[j]==r[j])
            {
                sum++;
                break;
            }
        }
    }
    cout<<sum<<endl;
    cout<<setprecision(6)<<fixed<<sum/1000000;
}
/*
两个整数数组M和R,
你们协商为即将到来的连续整数天数D（
当前天数包括当前天数且为0），
如果整数i满足D mod M[i] = R[i]则洗你盘子，
否则你的室友洗。这个喜欢方案你。
M和R现给出，请编程计算你洗盘子的可能性（假设之后有无数天）。
*/

#include <iostream>
#include <set>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N;
    int M[17], R[17];
    cin >> N;
    for (int i = 1; i <= N; ++i)
        cin >> M[i];
    for (int i = 1; i <= N; ++i)
        cin >> R[i];

    double res = 0;
    double prev_res = -1;
    int Ndays = 0;
    for (int D = 1; true; ++D){
        for (int i = 1; i <= N; ++i){
            if (D % M[i] == R[i]){
                ++Ndays;
                break;
            }
        }
        prev_res = res;
        res = double(Ndays)/double(D);
        //cout <<D<<"  "<<prev_res<<"   "<<res<<endl;
        if ((fabs(res - prev_res) < 1e-5) &&(D > 16)){
            cout << res << endl;
            break;
        }
    }
/*
    set<int> Days;
    int maxM = 0;
    double result = 0;
    for (int i = 1; i <= N; ++i){
        maxM = max(maxM,M[i]);
        int K = 0;
        for (int D = 1; D <= M[i]; ++D){
            if (D % M[i] == R[i]){
                if (Days.find(D) == Days.end()){
                    Days.insert(D);
                    ++K;
                }
            }
        }
        result += double(K)/double(M[i]);
    }

    double result = 0;
    for (set<int>::iterator it = Days.begin(); it != Days.end(); ++it){
        ++result;
       // cout <<"D = "<<*it<<endl;
    }
    result /= maxM;

   // cout.precision(20);
   // cout << result << endl;
    printf("%0.7g",result);*/
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define cont continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()

/*int pr[100000],prnum[1000001];

void sieve()
{
    int i,j;
    for(i=1;i<=1000000;i++)
        prnum[i]=i+1;
    for(i=1;i<=1000000;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=1000000;j+=prnum[i])
                    prnum[j]=-1;
    j=1;
    for(i=1;i<=1000000;i++)
        if(prnum[i]!=-1)
            pr[j++]=prnum[i];
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*func(i-1);
}*/

int main()
{
    ios_base::sync_with_stdio(0);
    ll int i,mx,j,x,n,cnt=0,m,y;
    cin>>n;
    mx=0;
    ll in[n+1],r[n+1];
    fr(i,1,n)
    {
        cin>>in[i];
        mx=max(in[i],mx);
    }
    fr(i,1,n)
    {
        cin>>r[i];
    }
    fr(i,0,mx-1)
    {
        fr(j,1,n)
        {
            if(i%in[j]==r[j])
                cnt++;
        }
    }
    double ans;
    ans=(cnt*1.0)/mx;
    //n=pow(2,n);
    x=1;
    x=x<<n;
    //fr(i,1,n)
    //{
        //x*=2;
    //}
    cout<<setprecision(6)<<fixed<<ans;
}

#include <fstream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

ifstream cin ("input.txt");
ofstream cout ("output.txt");

vector<int> m, r;
int n, cnt = 0;

void solve () {
  for (int i = 1; i <= 100; i++) {
    for (int j = 0; j < n; j++) {
      if (i % m[j] == r[j]) {
        cnt++;
        break;
      }
    }
  }
}

int main() {
  cin >> n;
  m.resize(n);
  r.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  solve();
  double ans = (double)cnt / 100.0;
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,a[20],b[20],tot;
    int max = 100000;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<max;i++){
        for(int j=0;j<n;j++){
            if(i%a[j]==b[j])
                tot++;
        }
    }
    cout<<setprecision(13)<<double(tot)/max<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[17];
    for(int i=1;i<=16;i++) a[i]=i;
    int sum=1,max=16;
    while(sum<16){
        for(int i=1;i<=16;i++){
            a[i]+=((max-a[i])/i)*i;
            if(a[i]==max) sum++;
              else a[i]+=i,max=a[i],sum=1;
        }
    }
    printf("%d",max);
    return 0;
}

#include <iostream>

int main()
{
    int N, M[16], R[16], count = 0;
    float percent;

    std::cin >> N;

    for (int i = 0; i < N; i++)
        std::cin >> M[i];

    for (int i = 0; i < N; i++)
        std::cin >> R[i];

    for (int i = 0; i < N; i++)
        if(i % M[i] == R[i])
            count ++;

    percent = (float)count/(float)(N+1);

    std::cout << percent;
    return 0;

}

//made by kuailezhish
//gl && hf
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <stack>
#include <sstream>
#include <complex>
#include <cstring>
#include <ctime>
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define lINF 0x3f3f3f3f3f3f3f3fll
#define dINF 1e30
#define eps 1e-8
#define lld long long
#define sqr(x) ((x)*(x))
#define ab(x) (((x)>0) ? (x) : -(x))
#define PI 3.14159265358979323846
#define psl pair<sting,lld>
#define pll pair<lld,lld>
#define pii pair<int,int>
#define mp make_pair
#define er(i) (1ll<<(i))
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define cp complex<double>
#define here printf("!!!!!!!!\n");
#define foreach(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define upmin(a,b) {if ((a)>(b)) (a)=(b);}
#define upmax(a,b) {if ((a)<(b)) (a)=(b);}
#define upmod(a,b) (a)=((a)%(b)+(b))%(b)
#define equ(a,b) (fabs(a-b)<eps)
#define rin freopen("in.txt","r",stdin)
#define pout freopen("out.txt","w",stdout)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define maxn 100

int a[maxn], b[maxn];
int n;

int main() {
    scanf("%d", &n);
    int mm = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        mm = max(mm, a[i]);
    }
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    int ans = 0;
    for (int i = 0; i < mm; i++) {
        int flag = 0;
        for (int j = 0; j < n; j++){
            if (i % a[j] == b[j]) {
                flag = 1;
                break;
            }
        }
        if (flag) {
            ans++;
        }
    }
    printf("%.6lf\n", 1.0 * ans / mm);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int M[20],R[20];
int main()
{
    int n;
    int day,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>M[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>R[i];
    }
    for(day=0;cnt<n;)
    {day++;
        int flag=0;
        for(int i=1;i<=n;i++)
            if(day%M[i]==R[i])
        {
             flag++;
        }
        if(flag==1)
        {
            cnt++;
        }

    }
    printf("%.9lf\n",(double)cnt/(double)(day));
    return 0;
}

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 1; i <= int(n); i++)
#define lli long long
#define mp make_pair
#define pi pair<int,int>
#define pli pair<lli,lli>
#define pb push_back
#define x first
#define y second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const double EPS = 1e-24;
const lli mod = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
const double PI = 3.14159265359;
int INF = 2147483645;
lli INFINF = 9223372036854775807;

template <class T>T Max2(T a,T b){return a<b?b:a;}
template <class T>T Min2(T a,T b){return a<b?a:b;}
template <class T>T Max3(T a,T b,T c){return Max2(Max2(a,b),c);}
template <class T>T Min3(T a,T b,T c){return Min2(Min2(a,b),c);}
template <class T>T Max4(T a,T b,T c,T d){return Max2(Max2(a,b),Max2(c,d));}
template <class T>T Min4(T a,T b,T c,T d){return Min2(Min2(a,b),Max2(c,d));}

using namespace std;
lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m){lli x=a*b;x%=m;return x;}

pi operator - (pi A,pi B) { return mp(A.x-B.x,A.y-B.y); }
lli operator * (pi A,pi B) { return A.x*B.y-A.y*B.x; }
typedef vector< int > vi;
typedef vector< vi > vvi;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,d=0,b=0;
double a;
cin>>n;
int m[n],r[n];
forn(i,n) cin>>m[i];
forn(i,n) cin>>r[i];
for(d=0;d<n;d++){
	forn(i,n){
		if((d%m[i])==r[i]){
			b++;
			break;
		}
	}
}
//cout<<b;
a = (double)b*(1.0000)/(double)(n+1);
printf("%.6f",a);
}

// rc.cpp : Defines the entry point for the console application.
//

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>

using namespace std;

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long long uint64;
typedef long long sint64;

uint m[16],
     r[16];

double q = 0;

uint gcd(uint x, uint y)
{
    if (x == 0)
        return y;

    return gcd(y % x, x);
}

void calc(uint x)
{
    uint v = 0,
         o = 0,
         b = 1;
    while (x)
    {
        if (x & 1)
        {
            ++o;
            uint g = gcd(b, m[v]);
            b = b * (m[v] / g);
        }
        ++v;
        x >>= 1;
    }

    if (o & 1)
        q += 1. / (double)b;
    else
        q -= 1. / (double)b;
}

int main(int argc, char* argv[])
{
    uint n;
    cin >> n;

    for (uint i = 0; i < n; ++i)
        cin >> m[i];

    for (uint i = 1; i < (1 << n); ++i)
    {
        calc(i);
    }

    printf("%.5f\n", q);
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
long long a[1005],n;
signed main()
{
    scanf("%d", &n);
    for (register int i(0);i<n;++i) scanf("%lld",&a[i]);
    sort(a,a+n);
    for (register int i(0);i<(n>>1);++i) printf("%lld %lld ",a[i],a[n-i-1]);
    if (n&1) printf("%lld",a[n>>1]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int M[20],R[20];
int main()
{
    int n;
    int day,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>M[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>R[i];
    }
    for(day=0;cnt<n;)
    {
        int flag=0;
        for(int i=1;i<=n;i++)
            if(day%M[i]==R[i])
        {
             flag++;
        }
        if(flag==1)
        {
            day++;
            cnt++;
            continue;
        }
        else
            break;
    }
    printf("%.9lf\n",(double)cnt/(double)(day+1));
    return 0;
}

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int n,m[100001],r[100001],ge=0;
    double ans;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
       cin>>m[i]>>r[i];
    }
    for(int i=0;i<=1000000;i++)
      for(int j=1;j<=n;j++)
      {
        if(i%m[j]==r[j])
        {
          ge++;
          break;
        }
      }
    ans=1.0*ge/1000001;
    printf("%f",ans);
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, me = 0, rm = 0;
	cin >> n;
	int m[n], r[n];
	for(int i = 0; i < n; i++) cin >> m[i];
	for(int i = 0; i < n; i++) cin >> r[i];
	for(int i = 0; i < n; i++)
	{
		if(i % m[i] == r[i]) me++;
		else rm++;
	}
	cout << setiosflags(ios::fixed) << setprecision(6) << (float) max(me, rm) / (n+1) << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define forf(i,n) for(int i = 0; i < int(n); i++)
#define fors(i,n) for(int j = i; j < int(n); j++)
#define forb(i,n) for(int i = n-1; i >=0; i--)
typedef long long ll;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
bool des(int i, int j) { return i > j; }
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m[16],r[16],max=0,cnt=0,flag;
cin >> n;
forf(i,n)
{
	cin >> m[i];
	if(m[i]>max)
	max=m[i];
}
forf(i,n)
cin >> r[i];
forf(i,max)
{
	flag=0;
	forf(j,n)
	if(i%m[j]==r[j])
	flag=1;
	if(flag==1)
	cnt++;
}
cout << (double)cnt/max;

}

#include <bits/stdc++.h>

using namespace std;

int m[20];
int r[20];

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> m[i];
	}
	for (int i = 0; i < n; ++i){
		cin >> r[i];
	}
	int tot = 0;
	for(int i = 0; i < 5000000; i++){
		for(int k = 0; k < n; k++)
			if(i % m[k] ==  r[k]){
				tot++;
				continue;
			}
	}
	double ans = (double)tot/5000000.0;
	cout << ans << endl;
	return 0;
}

#include <iostream>

using namespace std;

int m[16], r[16];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> m[i];
    for (int i = 0; i < n; i++)
        cin >> r[i];
    double a = 0, b = 0;
    for (int k = 0; k < 10000; k++) {
        bool flag = false;
        for (int i = 0; i < n; i++)
            flag = flag | (k % m[i] == r[i]);
        if (flag) a += 1.0;
        b += 1.0;
    }
    cout.precision(6);
    cout << a/b;
    return 0;
}

#include<bits/stdc++.h>
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	int n;
	int m[18],r[18];
	scanf("%d",&n);
	int lcm=1;
	for(int i=0;i<n;i++){
		scanf("%d",&m[i]);
		lcm=(lcm*m[i])/gcd(lcm,m[i]);
	}
	for(int i=0;i<n;i++)
		scanf("%d",&r[i]);
	int c=0;
	for(int i=0;i<lcm-1;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i%m[j]==r[j])
				c++;
		}
	}
	double ans=(double)(c)/(double)lcm;
	printf("%lf\n",ans );

	return 0;
}

// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

LL lcm( LL a, LL b ) {
    return a/__gcd(a,b)*b;
}

const int N=16;
int n;
LL a[N],b[N];
int main() {
    R(n);
    REP(i,n) R(a[i]);
    REP(i,n) R(b[i]);
    LL m=1;
    REP(i,n) m=lcm(m,a[i]);
    LL s=0;
    for ( int i=1; i<(1<<n); i++ ) {
        LL t=1;
        for ( int j=0; j<n; j++ ) if ( (i>>j)&1 ) t=lcm(t,a[j]);
        int sg=(__builtin_popcount(i)%2==1 ? +1 : -1);
        s+=sg*(m/t);
    }
    double ans=1.0*s/m;
    printf("%.14f\n",ans);
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
#define ll long long

map<ll,bool>vis;

ll gcd(ll a,ll b)
{
    if(b>a)swap(a,b);
    ll x=a,y=b;
    while(b!=0)
    {
        ll r = a%b;
        a=b;
        b=r;
    }
    ll mul = (x/a)*y;
}
int main()
{
    int n;
    cin >> n;

    int ara[n+2],bara[n+2],i,mul=1,lcm;

    for(i=0;i<n;i++){cin >> ara[i]; mul=gcd(mul,ara[i]);}
    for(i=0;i<n;i++)cin >> bara[i];
    //cout << mul << "\n";
        int j,count=0;

    for(i=0;i<n;i++)
    {
        for(j=bara[i];j<=mul;j+=ara[i])
        {
           // cout << j << "\n";
            vis[j]=1;

        }
    }
    for(i=1;i<=mul;i++)
    {
        if(vis[i]==1)count++;
    }
    double ans = (double)count/(double)mul;

    printf("%.7lf\n",ans);
}

#include <iostream>

using namespace std;

int m[16];
int r[16];

int main()
{
    int n;
    cin >> n;
    int max = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> m[i];
        if (max < m[i])
            max = m[i];
    }
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> r[i];
    }

    double ans = 0;
    for ( int i = 0 ; i < max ; i++ ) {
        for ( int j = 0 ; j < n ; j++ ) {
            if (i % m[j] == r[j]) {
                ans += 1.0;
                break;
            }
        }
    }

    ans /= max;

    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int m[20], r[20];
    for(int i = 0; i < n; i++) cin >> r[i];
    for(int i = 0; i < n; i++) cin >> m[i];

    int you = 0;
    for(int i = 0; i <= n; i++) {
            for(int k = 0; k < n; k++)
                if(i % r[k] == m[k]) {
                    you++;
                    break;
                }
    }
    cout << (((double)you) / (double)(n+1))<< endl;
}

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    long double sum = 0;
    int maxi = 0;
    for (int i = 0; i < n; i++){
        if (maxi < a[i]){
            maxi = a[i];
        }
    }
    for (int i = 0; i < maxi; i++){
        int flag = 0;
        for (int j = 0; j < n; j++){
            if (flag == 0 && i % a[j] == b[j]){
                flag = 1;
                sum++;
            }
        }
    }
    cout << sum/maxi;
}

#include<bits/stdc++.h>
#define Max 1000000
using namespace std;
int n;
int a[20];
int b[20];
int ans;
inline int read(){
    int s=0;
    char c=getchar();
    while(!isdigit(c))
        c=getchar();
    while(isdigit(c)){
        s=(s<<1)+(s<<3)+c-'0';
        c=getchar();
    }
    return s;
}
int main(){
    int i,j;
    n=read();
    for(i=1;i<=n;i++)
        a[i]=read();
    for(i=1;i<=n;i++)
        b[i]=read();
    for(j=0;j<Max;j++)
        for(i=1;i<=n;i++)
            if(j%a[i]==b[i])
            {
                ans++;
                break;
            }
    printf("%lf",ans/1.0000000);
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define cont continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()

/*int pr[100000],prnum[1000001];

void sieve()
{
    int i,j;
    for(i=1;i<=1000000;i++)
        prnum[i]=i+1;
    for(i=1;i<=1000000;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=1000000;j+=prnum[i])
                    prnum[j]=-1;
    j=1;
    for(i=1;i<=1000000;i++)
        if(prnum[i]!=-1)
            pr[j++]=prnum[i];
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*func(i-1);
}*/

int main()
{
    ios_base::sync_with_stdio(0);
    ll int i,mx,j,x,n,cnt=0,m,y;
    cin>>n;
    mx=0;
    ll in[n+1],r[n+1];
    fr(i,1,n)
    {
        cin>>in[i];
        mx=max(in[i],mx);
    }
    fr(i,1,n)
    {
        cin>>r[i];
    }
    fr(i,0,mx-1)
    {
        fr(j,1,n)
        {
            if(i%in[j]==r[j])
            {
                cnt++;
                break;
            }
        }
    }
    double ans;
    ans=(cnt*1.0)/mx;
    //n=pow(2,n);
    x=1;
    x=x<<n;
    //fr(i,1,n)
    //{
        //x*=2;
    //}
    cout<<setprecision(6)<<fixed<<ans;
}

//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <deque>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <stdint.h>
using namespace std;

#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair

#define ftn(i, n) for (int i = 0; i < n; ++i)
#define bte(a) (a).begin(), (a).end()
#define rbte(a) (a).rbegin(), (a).rend()

inline int in() { int x; scanf("%d", &x); return x; }

template<typename T> istream & operator >> (istream &in, vector<T> &vec)
{
	for(int i=0; i<vec.size();++i)
		in >> vec[i];
	return in;
}
template<typename T> ostream & operator << (ostream &out, const vector<T> &vec)
{
	for(int i=0; i<vec.size();++i)
		out << vec[i] << " ";
	return out;
}

#define name "sawmill"
const int INF=1e-6;
vector<vector<int> >f;
vector<int> color;
ll eds=0;
vector<bool> check;

int main()
{
	//freopen(name ".in", "r", stdin); freopen(name ".out", "w", stdout);
	//ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(4);
    int n;
    cin>>n;
    vector<int> arr1(n),arr2(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    cin>>arr2;
    int k=0;
    ld r;
    for(int i=1;i<=10000;i++)
    {
       for(int c=0;c<n;c++)
           if(i%arr1[c]==arr2[c])
           {
               k++;
               break;
           }
    }
    r=ld(k)/ld(10000);
    cout<<r;

	return 0;
}

#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

int lcm(int a, int b) {
    int m = a, n = b;
    while(m != n) {
        if (m > n)
            m -= n;
        else
            n -= m;
    }
    return a * b / m;
}

int main() {
    int number, input;
    vector<int> M, R;
    cin >> number;

    cin >> input;
    M.push_back(input);
    int D = input;
    for (int i = 1; i < number; ++i)
    {
        cin >> input;
        M.push_back(input);
        D = lcm(M[i], M[i-1]);
    }
    for (int i = 0; i < number; ++i)
    {
        cin >> input;
        R.push_back(input);
    }

    int prob = 0;
    for (int i = 0; i < D; i++) {
        bool found = false;
        for (int j = 0; j < number; j ++) {
            if (!found && R[j] == i % M[j]) {
                prob++;
                found = true;
            }
        }
    }

    cout << setprecision(4) << float(prob) / D << endl;

    return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int M[30],R[30];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>M[i];
    for(int i=0;i<n;i++)
        cin>>R[i];
    int a=0,b=0;
    double ans=1e90,ans2=1e89;
    int k=0;
    while(fabs(ans-ans2)>0.000001)
    {
        k++;
        for(int i=0;i<n;i++)
            if(k%M[i]==R[i])
            {
                a++;
                break;
            }
        ans2=ans;
        ans=a;
        ans=ans/(double(k));
    }
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main (void)
{
	int n;
	double ct = 0, ans;
	cin>>n;
	int R[n], M[n];
	for (int i = 0; i < n; i++)
	{
		cin>>M[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin>>R[i];
	}
	for (int i = 0; i < (n+1); i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i%M[j] == R[j])
			{
				ct++;
				break;
			}
		}
	}
	ans = ct/(n+1);
	cout<<ans;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (1<<28)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

void work ()
{
    int n;
    scanf ("%d",&n);
    LL a[300];
    for (int i=1;i<=n;i++)
    {
        scanf ("%I64d",&a[i]);
    }
    LL b[300];
    for (int i=1;i<=n;i++)
    {
        scanf ("%I64d",&b[i]);
    }
    double ans=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
        {
            if (i%a[j]==b[j])
            {
                //printf ("%d %d %d\n",i,a[j],b[j]);
                ans++;
            }
        }
    }
    printf ("%f\n",ans/((n+1)*n));
    return ;
}

int main ()
{
    #ifdef local
    freopen("data.txt","r",stdin);
    #endif
    work ();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i = 0; i <n;i++)
		cin>>a[i];
	for(int j=0;j<n;j++)
		cin>>b[j];
	float ans = 0;
	for(int day = 0; day<=n;day++)
	{
		for(int i=0;i<n;i++)
		{
			if(day % a[i] == b[i])
			{
				ans++;
				break;
			}
		}
	}
	cout<<fixed<<setprecision(6);
	cout<<ans/(n+1);
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[17],b[17];
	double ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	    scanf("%d",&b[i]);
    for(int i=0;i<1000000;i++)
        for(int j=1;j<=n;j++)
            if(i%a[j]==b[j]){
            	ans++;
            	break;
			}
	printf("%0.6lf",(double)ans*1.0/1000000.0);
    return 0;
}

#include <cstdio>
#include <algorithm>

long long gcd(long long a, long long b) {
	while (b > 0) {
		a %= b;
		std::swap(a, b);
	}
	return a;
}

int const N = 22;

std::pair<int, int> p[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &p[i].first);
	for (int i = 0; i < n; ++i) scanf("%d", &p[i].second);
	std::sort(p, p + n);
	n = std::unique(p, p + n) - p;
	long long LCM = 1;
	for (int i = 0; i < n; ++i) {
		LCM *= p[i].first / gcd(LCM, p[i].first);
	}
	long long ans = 0;
	for (int mask = 1; mask < (1 << n); ++mask) {
		long long lcm = 1;
		for (int i = 0; i < n; ++i) {
			if (((mask >> i) & 1) == 1) {
				lcm *= p[i].first / gcd(lcm, p[i].first);
			}
		}
		long long now = LCM / lcm;
		if (__builtin_popcount(mask) % 2 == 0) {
			now *= -1;
		}
		for (int i = 0; i < n; ++i) {
			if (((mask >> i) & 1) == 1) {
				for (int j = 0; j < n; ++j) {
					if (((mask >> j) & 1) == 1 && i != j) {
						if (p[i].first == p[j].first && p[i].second != p[j].second) {
							now = 0;
						}
					}
				}
			}
		}
		ans += now;
	}
	printf("%.15f\n", (double) ans / LCM);
}

#include<bits/stdc++.h>

using namespace std;

#define INF 18

int main() {
	cout.precision(7);
	int n;
	vector<int> m;
	vector<int> r;
	cin >> n;
	for( int i = 0 ; i < n ; ++i ){
		int x;
		cin >> x;
		m.push_back(x);
	}
	for( int i = 0 ; i < n ; ++i ){
		int x;
		cin >> x;
		r.push_back(x);
	}
	int wash = 0;
	for( int i = 0 ; i < INF ; ++i )
		for( int j = 0 ; j < n ; ++j )
			if(i % m[j] == r[j]){
				++wash;
				break;
			}
	cout << fixed << (double)wash/INF ;
//	cout << endl << fixed << wash << " " << INF;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    int a[n], b[n];

    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }

    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    long long pr = 1;
    for (auto elem : s)
        pr *= elem;
    int cnt1 = 0;

    for (int i = 0; i < min(pr, 10000000LL); i++) {
        for (int j = 0; j < n; j++) {
            if (i % a[j] == b[j]) {
                cnt1++;
                break;
            }
        }
    }

    cout << fixed << setprecision(6) << (cnt1 + .0) / pr << "\n";
}

#include<stdio.h>

long long int Day[1000000],m[12],r[12];
long long nzd(long long a, long long b)
{
     if(!b) return a;
     a%=b;
     return nzd(b,a);
}
int main()
{
long long int n,d=1,c=0,j,i;
double k=1;
scanf("%lld",&n);
for(i=0;i<n;i++)
scanf("%lld",&m[i]);
for(i=0;i<n;i++)
scanf("%lld",&r[i]);
for(i=0;i<n;i++)
{
d=d*m[i]/nzd(d,m[i]);
}
//printf("%lld\n",d);
for(i=0;i<d;i++)
{
for(j=0;j<n;j++){if(i%m[j]==r[j]){c++;break;}}
}
k=(double)c/(double)(d);
printf("%lf",k);
return 0;
}

#include <iostream>
#include <bitset>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {
	int n, mx = 0;
	cin >> n;
	int m[16], r[16];
	for (int i = 0; i < n; cin >> m[i], mx = max(mx, m[i]), ++i);
	for (int i = 0; i < n; cin >> r[i], ++i);
	double sum = 0;
	for (int i = 0; i < mx; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i % m[j] == r[j]) {
				sum += 1.0 / mx;
			}
		}
	}
	cout << sum;
	return EXIT_SUCCESS;
}

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 1; i <= int(n); i++)
#define lli long long
#define mp make_pair
#define pi pair<int,int>
#define pli pair<lli,lli>
#define pb push_back
#define x first
#define y second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const double EPS = 1e-24;
const lli mod = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
const double PI = 3.14159265359;
int INF = 2147483645;
lli INFINF = 9223372036854775807;

template <class T>T Max2(T a,T b){return a<b?b:a;}
template <class T>T Min2(T a,T b){return a<b?a:b;}
template <class T>T Max3(T a,T b,T c){return Max2(Max2(a,b),c);}
template <class T>T Min3(T a,T b,T c){return Min2(Min2(a,b),c);}
template <class T>T Max4(T a,T b,T c,T d){return Max2(Max2(a,b),Max2(c,d));}
template <class T>T Min4(T a,T b,T c,T d){return Min2(Min2(a,b),Max2(c,d));}

using namespace std;
lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m){lli x=a*b;x%=m;return x;}

pi operator - (pi A,pi B) { return mp(A.x-B.x,A.y-B.y); }
lli operator * (pi A,pi B) { return A.x*B.y-A.y*B.x; }
typedef vector< int > vi;
typedef vector< vi > vvi;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,d=0,b=0;
double a;
cin>>n;
int m[n],r[n];
forn(i,n) cin>>m[i];
forn(i,n) cin>>r[i];
for(d=0;d<=n;d++){
	forn(i,n){
		if(m[i]!=0 && (d%m[i])==r[i]){
			b++;
			break;
		}
		else if(m[i]==0 && r[i]==0){
			b++;
			break;
		}
	}
}
//cout<<b;
a = (double)b*(1.000000)/(double)(n+1);
printf("%.6f",a);
}

#include<bits/stdc++.h>
using namespace std;
int m[17],r[17];
int sum;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>m[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>r[i];
    }
    for(int i=0;i<1000000;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i%m[j]==r[j])
            {
                sum++;
                break;
            }
        }
    }
    double ans=(double)(sum/1000000.0);
}

#include <iostream>
#include <vector>
using namespace std;

int A[16];
int B[16];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	for(int i=0;i<n;i++){
		cin >> B[i];
	}
	int ans = 0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<n;j++){
			if(i % A[j] == B[j]){
				ans++;
				break;
			}
		}
	}
	cout << (long double)ans / (n + 1);
}

#include <iostream>
#include <set>
#include <cstdio>
#include <cmath>

using namespace std;
typedef unsigned long long ull;

int main()
{
    int N;
    int M[17], R[17];
    cin >> N;
    for (int i = 1; i <= N; ++i)
        cin >> M[i];
    for (int i = 1; i <= N; ++i)
        cin >> R[i];

    double res = 0;
    double prev_res = -1;
    ull Ndays = 0;
    for (ull D = 1; true; ++D){
        for (int i = 1; i <= N; ++i){
            if (D % M[i] == R[i]){
                ++Ndays;
                break;
            }
        }
        prev_res = res;
        res = double(Ndays)/double(D);
        //cout <<D<<"  "<<prev_res<<"   "<<res<<endl;
        if ((fabs(res - prev_res) < 1e-5) &&(D > 100)){
            cout << res << endl;
            break;
        }
    }
/*
    set<int> Days;
    int maxM = 0;
    double result = 0;
    for (int i = 1; i <= N; ++i){
        maxM = max(maxM,M[i]);
        int K = 0;
        for (int D = 1; D <= M[i]; ++D){
            if (D % M[i] == R[i]){
                if (Days.find(D) == Days.end()){
                    Days.insert(D);
                    ++K;
                }
            }
        }
        result += double(K)/double(M[i]);
    }

    double result = 0;
    for (set<int>::iterator it = Days.begin(); it != Days.end(); ++it){
        ++result;
       // cout <<"D = "<<*it<<endl;
    }
    result /= maxM;

   // cout.precision(20);
   // cout << result << endl;
    printf("%0.7g",result);*/
    return 0;
}

#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

int a[100], b[100], ans, MAX;

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		MAX = max(MAX, a[i]);
	}
	for(int i = 0; i < n; i++)
		cin >> b[i];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(i % a[j] == b[j])
			{
				ans++;
				break;
			}
	cout << setprecision(9) << fixed << 1. * ans / (1. * MAX) << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef pair<int, int> pair_ii;
typedef pair<long long, long long> pair_LL;
typedef pair<string, string> pair_ss;

#define fori(i, s, n) for (int i = s; i < n; ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

LL const modul = 1000000000000000;

LL mod_sum(LL x, LL y) {
	return (x + y) % modul;
}

LL mod_sub(LL x, LL y) {
	if (x > y) {
		return (x - y) % modul;
	}
	else {
		return (modul + x - y) % modul;
	}
}

LL mod_mpl(LL x, LL y) {
	return (x * y) % modul;
}

void set_precise(int n) {
	cout << fixed;
	cout << setprecision(n);
}

int m[16];
int r[16];
int primes[16] = {0};

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	fori(i, 0, n) {
		int x;
		cin >> x;
		m[i] = x;
		switch(x) {
		case 2:
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 3:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			break;
		case 4:
			if (primes[2] < 2) {
				primes[2] = 2;
			}
			break;
		case 5:
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 6:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 7:
			if (primes[7] < 1) {
				primes[7] = 1;
			}
			break;
		case 8:
			if (primes[2] < 3) {
				primes[2] = 1;
			}
			break;
		case 9:
			if (primes[3] < 2) {
				primes[3] = 2;
			}
			break;
		case 10:
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 11:
			if (primes[11] < 1) {
				primes[11] = 1;
			}
			break;
		case 12:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[2] < 2) {
				primes[2] = 2;
			}
			break;
		case 13:
			if (primes[13] < 1) {
				primes[13] = 1;
			}
			break;
		case 14:
			if (primes[7] < 1) {
				primes[7] = 1;
			}
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 15:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 16:
			if (primes[2] < 4) {
				primes[2] = 4;
			}
			break;
		}
	}
	fori(i, 0, n) {
		cin >> r[i];
	}
	int lcd = 1;
	fori(i, 0, 15) {
		fori(j, 0, primes[i]) {
			lcd *= i;
		}
	}
	LL days = 0;
	fori(i, 0, lcd) {
		fori(j, 0, n) {
			if ((i % m[j]) == r[j]) {
				++days;
				break;
			}
		}
	}
	double d_days = days;
	double overall = lcd;
	double ans = d_days / overall;
	set_precise(6);
	cout << ans;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int M[20],R[20];
int main()
{
    int n;
    int day,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>M[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>R[i];
    }
    for(day=0;cnt<n;day++)
    {
        int flag=0;
        for(int i=1;i<=n;i++)
            if(day%M[i]==R[i])
        {
             flag++;
        }
        if(flag==1)
        {
            cnt++;
        }

    }
    printf("%.9lf\n",(double)cnt/(double)(day+1));
    return 0;
}

#include <vector>
#include <stdio.h>
#include <string.h>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
typedef long long ll;
//typedef long double d;
using namespace std;

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //freopen("read.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll n;
    cin >> n;
    double x,out=1;
    for(int i=0;i<n;i++)
    {
        cin >> x;
        out=min(out,(double)1/x);
    }
    for(int i=0;i<n;i++)
    {
        cin >> x;
    }
    cout << fixed<< setprecision(6)<<1-out<< endl;
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <int> vec1, vec2;
    long long target = 1;
    for (int i=0; i<n; i++) {
    	int x;
    	cin >> x;
    	vec1.push_back(x);
    	target *= (long long)x;
    }
    for (int i=0; i<n; i++) {
    	int x;
    	cin >> x;
    	vec2.push_back(x);
    }
    int ans1 = 0, ans2 = 0;
    cout << target << endl;
    for (int i=0; i<target; i++) {
    	bool p = false;
    	for (int j=0; j<n; j++) {
	    	if (i % vec1[j] == vec2[j]) {
	    		p = true;
	    		break;
	    	}
	    }
	    if (p) ans1++; else ans2++;
    }
    double answer = (ans1 + 0.0) / (ans1 + ans2 + 0.0);
    cout << answer << endl;
}

#include<bits/stdc++.h>

using namespace std;
#define ll long long

map<ll,bool>vis;

ll gcd(ll a,ll b)
{
    if(b>a)swap(a,b);
    ll x=a,y=b;
    while(b!=0)
    {
        ll r = a%b;
        a=b;
        b=r;
    }
    ll mul = (x/a)*y;
}
int main()
{
    ll n;
    cin >> n;

    ll ara[n+2],bara[n+2],i,mul=1;

    for(i=0;i<n;i++){cin >> ara[i]; mul=gcd(mul,ara[i]);}
    for(i=0;i<n;i++)cin >> bara[i];
    //cout << mul << "\n";
        ll j,count=0;

    for(i=0;i<n;i++)
    {
        for(j=bara[i];j<=mul;j+=ara[i])
        {
           // cout << j << "\n";
            vis[j]=1;

        }
    }
    for(i=1;i<=mul;i++)
    {
        if(vis[i]==1)count++;
    }
    double ans = (double)count/(double)mul;

    cout << ans ;
}

#include <iostream>
using namespace std;
int main(){
           int n,m[42],r[42],d;
           double c;
           cin>>n;
	for (int i=0;i<n;i++)
                      cin >> m[i];
	for (int i=0;i<n;i++)
                      cin>>r[i];
	for (d=0; d<10000000; d++){
		for (int i=0; i<n; i++){
			if (d%m[i] == r[i]) {
				c+=1;
				break;
			}
                      }
           }
	cout<<c/10000000;
return 0;
}

#include <bits/stdc++.h>

using namespace std;

int M[100], R[100], q, n;

double ans;

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> M[i], q = max(q, M[i]);
	for(int i = 0; i < n; ++i) cin >> R[i];
	for(int i = 0; i < q; ++i){
		for(int j = 0; j < n; ++j){
			if(i % M[j] == R[j]){
				ans += 1;
				break;
				}
			}
		}
	printf("%.10f", ans / (double) q);
	}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,a[20],b[20],tot;
    int max = 100000;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<max;i++){
        for(int j=0;j<n;j++){
            if(i%a[j]==b[j])
                tot++;
        }
    }
    cout<<setprecision(13)<<double(tot)/max<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i, a, b) for(int i = a; i <= b; i++)
#define fo(i, a, b) for(int i = a; i < b; i++)
#define fod(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int INF = 1e9, N = 100010;
const ll INFL = 1e18;

typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

int n, R[N], M[N];
int lcm;
int res;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n; ff(i, 1, n) cin >> M[i]; ff(i, 1, n) cin >> R[i];
	lcm = 1;
	ff(i, 1, n) lcm = (lcm * M[i] / __gcd(lcm, M[i]));
	cout << lcm << endl;
	fo(i, 0, lcm) {
		ff(j, 1, n) if (i % M[j] == R[j]) { res++; break; }
	}
	cout << setprecision(4) << fixed << (double)res / lcm << endl;
}

/*
   Mayank Pratap Singh
   MNNIT, 2nd year IT

   AC ho.
*/
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define MOD 1000000007

typedef long long ll;
typedef long double ld;

const int INF=(int)(1e9);
const ll INF64=(ll)(1e18);
const ld EPS=1e-9;
const ld PI=3.1415926535897932384626433832795;

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef vector<list<int> > vl;
typedef map<int,int> mi;
typedef map<string,int> ms;
typedef set<int> si;

ll power(int base,int expo){

    if(expo==0)
    	 return 1;

    ll f=power(base,expo/2);

    if(expo%2==0)
        return f*f;

    else
        return base*f*f;

}

int main(){

  int n;

  scanf("%d",&n);

  int r[20],m[20];

  int tdays=0,wdays=0;

  for(int i=0;i<n;++i){
     scanf("%d",&m[i]);
     tdays=max(tdays,m[i]);
  }

  for(int i=0;i<n;++i)
  	 scanf("%d",&r[i]);

  for(int i=0;i<tdays;++i){

      for(int j=0;j<n;++j){

          if(i%m[j]==r[j]){

              ++wdays;
              break;
          }
      }
  }

  printf("%0.6lf\n",wdays*1.0/tdays);

}

// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

LL lcm( LL a, LL b ) {
    return a/__gcd(a,b)*b;
}

const int N=16;
int n;
LL a[N],b[N];
bool good[N][N];

int main() {
    R(n);
    REP(i,n) R(a[i]);
    REP(i,n) R(b[i]);
    REP(i,n) REP(j,n) REP(k,1000) if ( k%a[i]==b[i] && k%a[j]==b[j] ) good[i][j]=1;
    LL m=1;
    REP(i,n) m=lcm(m,a[i]);
    LL s=0;
    for ( int i=1; i<(1<<n); i++ ) {
        LL t=1;
        REP(j,n) if ( (i>>j)&1 ) {
            REP(k,j) if ( ((i>>k)&1) && !good[j][k] ) {
                t=-1;
                j=k=N;
            }
            t=lcm(t,a[j]);
        }
        if ( t==-1 ) continue;
        int sg=(__builtin_popcount(i)%2==1 ? +1 : -1);
        s+=sg*(m/t);
    }
    double ans=1.0*s/m;
    printf("%.14f\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	short f=1;x=0;char c=getchar();
	while(!isdigit(c)){ if(c=='-')f=-1;c=getchar(); }
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	x*=f;
}
template<typename T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void writeln(T x){
	write(x),putchar('\n');
}
int main(){
    int n,a[20],b[20],ans=0;read(n);
    for(int i=1;i<=n;i++)read(a[i]);
    for(int i=1;i<=n;i++)read(b[i]);
    for(int j=0;j<=720720;j++)
        for(int i=1;i<=n;i++)
            if(j%a[i]==b[i]){ ans++;break; }
    cout<<ans/1000000.0<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int m[16];
int r[16];

int main()
{
    int n;
    cin >> n;
    int max = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> m[i];
        if (max < m[i])
            max = m[i];
    }
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> r[i];
    }

    double ans = 0;
    cout << max << endl;
    for ( int i = 0 ; i < max ; i++ ) {
        for ( int j = 0 ; j < n ; j++ ) {
            if (i % m[j] == r[j]) {
                ans += 1.0;
                break;
            }
        }
    }

    ans /= max;

    cout << ans << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int N, M[17], R[17], days, maxi;
int main()
{
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &M[i]), maxi = max(maxi, M[i]);
	for(int i = 0; i < N; i++) scanf("%d", &R[i]), maxi = max(maxi, M[i]);

	for(int D = 0; D < maxi; D++)
	{
		for(int i = 0; i < N; i++)
		{
			if(D % M[i] == R[i]) days++;
		}
	}

	//cout << days << endl;
	double ans = (days * 100) / (double)maxi;
	ans = (ans / 100.0);
	printf("%4f", ans);
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n,i;
	float m,r,ans=0;
	cin>>n;
	for(i=0;i<n;++i)
	{
		cin>>m;
		if(i==0)
		ans=1/m;
		else
		ans=ans+((1-ans)*(1/m));
	}
	printf("%0.4f",ans);
	// your code goes here
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,n,sum,m[16],r[16];
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m[i]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&r[i]);
    }
    for(i=0;i<1000000;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i%m[j]==r[j])
            {
                sum++;
                break;
            }
        }
    }
    printf("%.6lf",double(sum*1.0/720720));
    return 0;
}

#include<cstdio>
#include<ctime>
#include<bits/stdc++.h>
using namespace std;
typedef int IT;
typedef double FUCKCF;
#define F for(int i=1;i<=n;i++)
#define F1 for(int i=1;i<=720720;i++)
#define Fj for(int j=1;j<=n;j++)
int main(){
	srand((unsigned)time(NULL));
	IT n,sum,m[rand()%1000+100],r[rand()%1000+100];
	scanf("%d",&n);
	F scanf("%d",&m[i]);
	F scanf("%d",&r[i]);
	F1 Fj if(i%m[j]==r[j]){++sum;break;}
	FUCKCF ans=(FUCKCF)sum/720720;
	printf("%6lf",ans);
	return 0;
}
//真他娘个傻逼CF
//CF生儿子没吊，生女儿没屄
//CF他妈妈嬲狒狒

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef pair<int, int> pair_ii;
typedef pair<long long, long long> pair_LL;
typedef pair<string, string> pair_ss;

#define fori(i, s, n) for (int i = s; i < n; ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

LL const modul = 1000000000000000;

LL mod_sum(LL x, LL y) {
	return (x + y) % modul;
}

LL mod_sub(LL x, LL y) {
	if (x > y) {
		return (x - y) % modul;
	}
	else {
		return (modul + x - y) % modul;
	}
}

LL mod_mpl(LL x, LL y) {
	return (x * y) % modul;
}

void set_precise(int n) {
	cout << fixed;
	cout << setprecision(n);
}

LL m[16];
LL r[16];
int primes[16] = {0};

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	fori(i, 0, n) {
		LL x;
		cin >> x;
		m[i] = x;
		switch(x) {
		case 2:
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 3:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			break;
		case 4:
			if (primes[2] < 2) {
				primes[2] = 2;
			}
			break;
		case 5:
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 6:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 7:
			if (primes[7] < 1) {
				primes[7] = 1;
			}
			break;
		case 8:
			if (primes[2] < 3) {
				primes[2] = 1;
			}
			break;
		case 9:
			if (primes[3] < 2) {
				primes[3] = 2;
			}
			break;
		case 10:
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 11:
			if (primes[11] < 1) {
				primes[11] = 1;
			}
			break;
		case 12:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[2] < 2) {
				primes[2] = 2;
			}
			break;
		case 13:
			if (primes[13] < 1) {
				primes[13] = 1;
			}
			break;
		case 14:
			if (primes[7] < 1) {
				primes[7] = 1;
			}
			if (primes[2] < 1) {
				primes[2] = 1;
			}
			break;
		case 15:
			if (primes[3] < 1) {
				primes[3] = 1;
			}
			if (primes[5] < 1) {
				primes[5] = 1;
			}
			break;
		case 16:
			if (primes[2] < 4) {
				primes[2] = 4;
			}
			break;
		}
	}
	fori(i, 0, n) {
		cin >> r[i];
	}
	LL lcd = 1;
	fori(i, 0, 15) {
		fori(j, 0, primes[i]) {
			lcd *= (LL)i;
		}
	}
	LL days = 0;
	fori(i, 0, lcd) {
		fori(j, 0, n) {
			if (i % m[j] == r[j]) {
				++days;
				break;
			}
		}
	}
	double d_days = (double)days;
	double overall = (double)lcd;
	double ans = d_days / overall;
	set_precise(5);
	cout << ans;
	return 0;
}

#include <fstream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

ifstream cin ("input.txt");
ofstream cout ("output.txt");

vector<int> m, r;
int n, cnt = 0;

void solve () {
  for (int i = 1; i <= 100; i++) {
    for (int j = 0; j < n; j++) {
      if (i % m[j] == r[j]) {
        cnt++;
        break;
      }
    }
  }
}

int main() {
  cin >> n;
  m.resize(n);
  r.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  solve();
  double ans = (double)cnt / 100.0;
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{

   // freopen("in.txt","r",stdin);
   int n ;
   cin>>n;
   int m[20] ,r[20];
   for(int i=0;i<n;i++) cin>>m[i];
   for(int i=0;i<n;i++) cin>>r[i];
 //   for(int i)
    int my =0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<n;j++){
            if(i%m[j]==r[j]) {
                my++;
                break;
            }
        }
    }
    cout<< (long double ) my /(long double) (n+1) <<endl;
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define forf(i,n) for(int i = 0; i < int(n); i++)
#define fors(i,n) for(int j = i; j < int(n); j++)
#define forb(i,n) for(int i = n-1; i >=0; i--)
typedef long long ll;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
bool des(int i, int j) { return i > j; }
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m[16],r[16],max=0,cnt=0,flag;
cin >> n;
forf(i,n)
{
	cin >> m[i];
	if(m[i]>max)
	max=m[i];
}
forf(i,n)
cin >> r[i];
forf(i,max+1)
{
	flag=0;
	forf(j,n)
	if(i%m[j]==r[j])
	flag=1;
	if(flag==1)
	cnt++;
}
cout << (double)cnt/max;

}

#include<stdio.h>

long long int Day[1000000],m[12],r[12];
long long nzd(long long a, long long b)
{
     if(!b) return a;
     a%=b;
     return nzd(b,a);
}
int main()
{
long long int n,d=1,c=0,j,i;
double k=1;
scanf("%lld",&n);
for(i=0;i<n;i++)
scanf("%lld",&m[i]);
for(i=0;i<n;i++)
scanf("%lld",&r[i]);
for(i=0;i<n;i++)
{
if(m[i]!=0)d=d*m[i]/nzd(d,m[i]);
}
//printf("%lld\n",d);
for(i=1;i<=d;i++)
{
for(j=0;j<n;j++){if(i%m[j]==r[j]){c++;j=n;}}
}
k=(double)c/(double)(d);
printf("%lf",k);
return 0;
}

#include <bits/stdc++.h>
using namespace std;

int M[20], R[20];

int main()
{
    int N;
    scanf("%d", &N);

    for(int i=0; i<N; i++)
        scanf("%d", &M[i]);
    for(int i=0; i<N; i++)
        scanf("%d", &R[i]);

    int ans = 0;

    for(int i=1; ; i++)
    {
        int flag = 0;

        for(int j=0; j<N; j++)
            if(i%M[j]!=R[j])
            {
                flag = 1;
                break;
            }

        if(!flag)
        {
            ans = i;
            break;
        }

        if(i==1000000)
        {
            ans = i;
            break;
        }
    }

    printf("%.6lf\n", 1 - 1.0/ans);

    return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> m(n), r(n);
	int maxn = 0;
	for (int i = 0; i < n; ++i){
		int temp;
		cin >> temp;
		if (temp > maxn) maxn = temp;
		m[i] = temp;
	}
	for (int i = 0; i < n; ++i){
		cin >> r[i];
	}

	vector<int> mon(maxn);

	for (int i = 0; i < n; ++i){
		for (int j = 0; j < maxn; ++j){
			if ((j+1) % m[i] == r[i]){
				mon[j] = 1;
			}
		}
	}

	double count = 0.0;
	for (auto x : mon){
		if (x != 0) count++;
	}
	double v = count / maxn;
	cout.setf(ios::fixed);
	cout<< setprecision(6) << v;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int vis[416001];
int m[20], r[20];

int main(){
	int n;
	scanf("%d", &n);
	int maxm = -1;
	for(int i = 0; i < n; i++){
		scanf("%d", m+i);
		maxm = max(maxm, m[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d", r+i);
	}
	memset(vis, 0, sizeof(vis));
	int num = 0;
	double pre = 0;
	double temp;
	for(int i = 1; ;i++){
		if(vis[i] == 2){
			num--;
			continue;
		}
		for(int j = 0; j < n; j++){
			if(i%m[j] == r[j]){
				vis[i]++;
				num++;
				break;
			}
		}
		temp = (double)1.0*num/i;
		if(temp-pre<=1e-4)break;
		pre = temp;
	}
	printf("%.6lf\n", temp);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define forn(i,a,n) for(int i = a; i < n; i++)
#define dbg(a) cout << #a << " = " << a << endl

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	int m[n];
	int r[n];
	int mx = 0;
	for(int i = 0; i < n; i++) cin >> m[i], mx = max(mx, m[i]);
	for(int i = 0; i < n; i++) cin >> r[i];

	set<int> days;
	cout.precision(6);
	cout.setf(ios::fixed);

	for(int i = 1; i <= mx; i++) {
		for(int j = 0; j < n; j++) {
			if(m[j] == 1 && r[j] == 1) {
				cout << 1.0;
				return 0;
			}
			if(i % m[j] == r[j]) {
				days.insert(i);
			}
		}
	}

	cout << (double) days.size() / mx;

	return 0;
}